Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Number larger than the largest datatype
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lastlegion




PostPosted: Sat May 29, 2010 12:17 pm   Post subject: Number larger than the largest datatype

Hey!
Thanks to project euler...i have had to write code to perform calculations on very large numbers. I tried programming in C but the numbers often exceed the size limit of the datatype...I expect the same result with PHP.
I was wondering if there is a way to store and perform arithemetic operations on such numbers.
My friend suggested storing each digit of the number as an element of an array...it would work fine but i'l need to write functions for the arithmetic operations.
Is there any other way? Rolling Eyes
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Sat May 29, 2010 12:46 pm   Post subject: RE:Number larger than the largest datatype

Arbitrary Precision Arithmetic is what you want.

There are libraries for both C and PHP to do this. Other languages (python, ruby) have this built in.

[edit] pretty much, library someone else made to do what your friend suggested. The libraries *should* be able to do all the usual stuff; arithmetic, powers, logarithms, roots, &c.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: