LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

what is the minimum value for data type double?

Solved!
Go to solution

... 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

 

 

0 Kudos
Message 1 of 3
(6,911 Views)
Solution
Accepted by topic author Wolfgang

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

Message 2 of 3
(6,904 Views)

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 

0 Kudos
Message 3 of 3
(6,889 Views)