![]() |
|
|
|
Registered
Join Date: Mar 2003
Posts: 10,322
|
programmers - very large numbers and c++
Anyone have a link to a library, etc. for working with very large numbers? Think squaring a 32 bit number, square rooting a 64 bit number, etc.
Can work with MS/Visual Studio or preferably with GCC/G++ Thanks!
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
B58/732
Join Date: Feb 2000
Location: Hot as Hell, AZ
Posts: 12,313
|
Like GMP? The GNU MP Bignum Library
__________________
ΜΟΛΩΝ ΛΑΒΕ I don't always talk to vegetarians--but when I do, it's with a mouthful of bacon. |
||
![]() |
|
Registered
Join Date: Feb 2004
Location: Decatur/Madison, Alabama
Posts: 1,192
|
The 32 bit Microsoft Visual Studio compilers can do floats or doubles right out of the box. Floats are 32 bit and the doubles are 64 bit. 64 bit seems to be enough precision for most calculations. The max value for a 32 bit float is 3.4*10e38 and the max value for a double is 1.7*10e308. How big of a number do you need?
Other libraries are geared toward very large numbers such as used in computing pi to 1 billion digits or prime number searches, etc. I think some of these libraries are referred to as arbitrary precision libraries because you can choose how many digits of precision the library will provide. It all costs in terms of memory and speed. If you are currently using float type variables in the C/C++ code then try changing them to a double and see if you get the response you would like. don't forget to take into account the change in size of any data structures using these types. It can mess you up with pointers and such depending on how the current code is written to access the data structures.
__________________
Rob Channell One Way Motorsports 1979 911SC mostly stock ![]() 1972 911T Targa now with a good 2.7 ![]() 1990 Miata (cheap 'n easy) 1993 C1500 Silverado (parts getter) |
||
![]() |
|
Registered
|
We were always told to convert it to a number between 0 and 10. Then you can multiply the number of decimals needed. Say if its "1234" being squared it would be:
(1234)^2 = 1522756 Divide 1234 by 1000, then square 1.234. Multiply the answer by 1e6 to get 1522756. |
||
![]() |
|
canna change law physics
|
Quote:
A lot the answer depends on the use.
__________________
James The pessimist complains about the wind; the optimist expects it to change; the engineer adjusts the sails.- William Arthur Ward (1921-1994) Red-beard for President, 2020 |
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,322
|
What is happening is...
A math instructor wants to offer a class based on working with number theory. Programming needed, but the math kids aren't programmers (neither is he, although he admits to some turbo pascal 25 years ago). So I hooked him up with a programming instructor who teaches basic C/C++. Match made in heaven - he gets his math stuff done, she gets projects for her students and the students get experience working with a "customer". I get happy too, 'cause I'm building them a custom dev environment in Linux if it can't be done in VS. The GMP library seems to work for a few tests, but I need to write a bit more code for more testing.
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
![]() |
canna change law physics
|
OK, then as I thought the decimal point solution (engineering notation) won't work.
You need basically and integer*128 or *256 or more. This might be a good assignment, because it can show the students the limitations of the computer and how computers really generate numbers.
__________________
James The pessimist complains about the wind; the optimist expects it to change; the engineer adjusts the sails.- William Arthur Ward (1921-1994) Red-beard for President, 2020 |
||
![]() |
|