Thursday, July 30, 2009

How Do You Combine Doubles To Allocate More Space In C++?

I'm definitely not a programmer, but I need to run a simulation in C++ for a project and I'm having trouble working with big numbers (just a double by itself isn't long enough, so the results are slightly off). My professor emailed me and told me to "combine 4 doubles" to get 128 bits per word. Also, if you know of any other way to allocate more space that would be great as well. Thanks!

How Do You Combine Doubles To Allocate More Space In C++?
-My professor emailed me and told me to "combine 4 doubles" to get 128 bits per word.-


Your professor clearly isn't a programmer himself, as the suggestion is nonsensical. One has to be careful about precision, as the CPU may have trouble supporting high levels of precision, especially that of floating point. You can read about the details with Google. But the short answer is you want to look for a math library or large number library that specializes in high precision mathematics.





Take a look at http://gmplib.org . It's a well known library.


No comments:

Post a Comment