I am trying to write a code , but the place where I got stuck is that to store a big number
10^100 . this big is the number
Any suggestions
I am trying to write a code , but the place where I got stuck is that to store a big number
10^100 . this big is the number
Any suggestions
Redefine your units. Very rarely does a single kind of quantity vary that much. Arbitrary precision libraries are not a bad idea... But if accuracy can be sacrificed for speed, you can use floating point.
You need a multi-precision arithmetic library.
The most popular is probably GNU MP - http://gmplib.org/
Do you need integer precision? If so, GMP, if not, a float or double will do.
Such big numbers (10^100) -- assuming with ^ you mean "to the power" -- won't fit in any of the integer types. You could use a floating point type (preferrably double
here) and pow()
, but you would still lose precision. If you really need integers with 100 digit or better precision, get one of the 3rd party BigInt implementations and use that. If you don't need 100 digit precision, then use double
, which is part of the language(s).