Number larger than the largest datatype
Author |
Message |
lastlegion
|
Posted: 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? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DtY
|
Posted: 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. |
|
|
|
|
|
|
|