| IWishIKnew (460) | |
I'm writing a Statistical Calculator for a videogame. Some of the statistics use numbers that are longer than 16 digits, and from what I can tell, a long double can only hold up to 15 digits (or double).Should I use a variable to store this data, or would using an algorithm to split it into smaller numbers and re-construct it from those numbers be more suitable? | |
|
|
|
| ResidentBiscuit (2207) | |
|
I'd just grab a library to handle this, unless you wanna handle it yourself. This one is pretty lighweight and will definitely cover any number you could want. http://www.ttmath.org/faq Or, http://gmplib.org/ I think is the more "official" library, though I do believe it is a bit larger. | |
|
Last edited on
|
|
| IWishIKnew (460) | |
| I would prefer to handle these numbers myself. | |
|
|
|
| Peter87 (3672) | |||
|
Floating point numbers are designed to be able to handle very small values and very large values. They can contain much more than 15 digits but only the 15 right-most digits will be without rounding errors, loosely speaking. You will get rounding errors but for many applications they are good enough. The precision of the different floating point numbers really depends on your compiler. You can run this program to find out.
| |||
|
Last edited on
|
|||
| IWishIKnew (460) | |
| Interesting, ty peter. I will investigate that. | |
|
|
|
| unstoppy (33) | |||
If you are using an int. You may use long long as a type which can represent upto 8 bytes integers.
| |||
|
|
|||