01-15-2009 06:57 AM
... a more academic question: what is the minimum value of the data type double? I thought that 'double' is the 8-byte IEEE standard, and what I remember this was +- 1.7E+-308. So the smallest number that is different from 0 should be 1.797E-308.
Therefore I was a little bit surprised when I looked at the data output of my CVI calculation, where I found numbers with exponents of E-319 or E-324 as the smallest value...
But I am sure that there is an explanation 🙂
Thanks for sharing it with me,
Wolfgang
Solved! Go to Solution.
01-15-2009 08:56 AM
The largest number is indeed of the order +1.7E+308; there is a corresponding smallest number of -1.7E+308. Note this is actually the most negative number, which by some reckoning is the smallest. For the small exponent range, things get a bit more complicated. 1E-308 can be represented to the full accuracy and resolution, but if you are prepared to lose some bits of precision, you can go down even further. For example:
double x, y, z:
x = 1E-300;
y = 1E7;
z = x / y; // Gives 1.000000000000000E-307
y = 1E8;
z = x / y; // Gives 9.999999999999999E-309
y = 1E18;
z = x / y; // Gives 9.999987484955998E-319
y = 1E23;
z = x / y; // Gives 9.881312916824931E-324
So as you can see, values smaller than 1E-308 are possible, but they become increasingly more inaccurate and should not be relied on.
JR
01-15-2009 10:57 AM
Hi JR,
thank you very much for your explanation. So the 16 bits of the mantissa are used to shift the exponent, reducing the number of 'effective' bits for the mantissa. This nicely explains E-324.
For my application, all these tiny values are equivalent to zero. The reason I was raising this issue is the fact that some programs such as OpenOffice do not know such numbers, they work correctly down to E-308, numbers such as 1.7e-317 are treated as text then. That's why I was wondering about the definition of the IEEE standard.
Wolfgang