Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
computing large numbers. powers of
Name: Ordinus Date: September 21, 2006 at 14:26:18 Pacific OS: Win XP pro SP2 CPU/Ram: IBM T60 Product: IBM
Comment:
I am trying to take the digits of a large number (has a maximum of 99 digits) and re assembling them as the original number. to do this i am using the d x 10^0 + d x 10^1 + ... etc. Im using exponent = pow(10,b) ;
but as b exeeds 9, the value of the exponent become wierd numbers. i have set exponent as double, long double, and long long int, but they all produce the same results. any ideas? thanks!
Name: Wolfbone Date: September 21, 2006 at 23:02:56 Pacific
Reply:
It's because of the inexact representation of floating point numbers. For example, only positive integers < about 10^16 (I think) can be represented exactly as doubles so the error in larger numbers is bound to show up at some point:
The way round the problem depends on exactly what you want to do.
0
Response Number 2
Name: Wolfbone Date: September 22, 2006 at 02:04:37 Pacific
Reply:
s/can be represented/can all be represented/
0
Response Number 3
Name: wizard-fred Date: September 22, 2006 at 22:24:52 Pacific
Reply:
There are high precision math packages that can handle n'th precision. They are slow because they work by using integer by parts, then combining. That will solve your rounding problem. It will be you problem to represent the math properly.
0
Response Number 4
Name: Guy Date: September 25, 2006 at 17:03:33 Pacific
Reply:
Yes, a high precision math package using (I read between the lines) C/C++.
Maybe (?) another language that has built in support for this: Java
Maybe (?) another language that has seamless built in support for this: Ruby
Kinda depends ....... right tool for the right job.
Summary: We were given a question as a project to create a class of a large number with the following specification class aLargeNumber { private: int*digit; long int length; /*a default constructor of length=...
Summary: I keep getting mathematical errors when trying to use numbers greater than about 2^32 in Fortran 77. I have to do this project in FORTRAN and as of now I can't see of any way to avoid using the multi...
Summary: [edit fixes to the script] Fishmonger, I downloaded and install perl(first time I have used it) and ran your script. It seems to be limiting the output with notation, is there any larger data types th...