I'm a bit stucked with storing number with maximum available precision:
double tmp = 569.232306826889043804840184748172760009765625L;
I'm trying to print it on the screen:
printf("%0.52f\n", tmp);
And that's what I've got:
569.2323068268890400000000000000000000000000000000000000
Is this the maximum precision which I can achieve?
P.S. I'm using Visual Studio 2008
A double is usually stored in IEEE 754 binary64 format.
A binary64 has 52 bits of precision, not 52 decimal digits - this is equivalent to at most 17 decimal digits, which is what you're displaying.
Is this the maximum precision which I can achieve?
Some platforms may provide a long double
which is actually bigger than a double
, but yours doesn't seem to.
If you want more precision, you can either use a library that exposes some larger/more precise type supported by your hardware (such as the 80-bit extended double), or an arbitrary-precision library that works in software.
That is the precision of type double
in your C implementation. Conformant C implementations also have a type long double
, which may offer greater precision.
If you need more precision than that then there are numeric libraries that provide arbitrary-precision numeric types and functions to operate on them. The GNU Multiple Precision Arithmetic Library is one such; it works on many platforms, including the ones relevant to you -- Win32 and Win64.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With