why is $2.2250738585072014\text{e}{-308}$ not a number?

2.5k Views Asked by At

In programming the min value of a float is: $$2.2250738585072014\text{e}{-308}$$

but when I type this into a calculator, it says Not a Number. what I am wondering is why this is an invalid number?

Note: I am only just finishing grade 8 math and haven't learned fully what the 'e' in an equation does. I think it has something to do with putting the number to the power of ten times the number after the e.

4

There are 4 best solutions below

3
On BEST ANSWER

You are correct about your interpretation of the $e$ stuff. Indeed, this value is

$2.2250738585072014 \cdot 10^{-308}$

Which is, to be sure, a number. It's just that, in order to properly store this number, the calculator will need a fair bit of memory to store it accurately, and you've essentially attempted to exhaust it.

4
On

In the so called "scientific notation" of numbers the e stands for 10 to the power of x. So in your case 2.22... times 10 to the power of -308. Your number happens to be the smallest number representable by the very common data type "double", a 64 bit binary floating point representation. So your calculator is unable to represent it because it is too small and wrongfully tells you it was not a number when in fact it is a number, simply too small.

2
On

This is indeed a number, it is extremely near by 0. Your number is approximately $$2 \cdot 10^{-308} = 0.\underbrace{00\ldots 0}_{307 \text{ zeros}}2 \; ,$$ which is slightly bigger than zero.

I don't know what you want to program, but one often wants to test, if such a result is zero. You should never do something like this:

res = 2.2E-10;
if (res == 0.0) { 
    Do something;
}

This is not good because of floating point arithmetic. Instead, you want to do something like this:

res = 2.2E-10;
epsilon = 1E-8; % A small value, to see, if our result is near enough at zero
if (abs(res - 0) < epsilon) { %Our value is 'near enough' at zero
    Do something;
}
0
On

It's a valid number alright. But any computer has only a limited number of combinations it can store as numbers. Suppose your computer's numbers consist of 4 decimal digits. Then it can represent the numbers 0000 to 9999, that's 10000 combinations. But the computer want to reserve some of these combinations as codes for things which aren't numbers. Suppose you want to calculate

$$ 0^0 $$

This doesn't represent a number, so the computer will use its "NaN" code (Not a Number) to represent the result. In our hypothetical computer it may reserve the number 9999 for this. Then, if you type in 9999, which looks like a normal number, the computer will say it's not a number.

Your calculator also reserves one combination of digits for the "NaN" code. It may look a bit random, but that's because you get to see the decimal representation. In binary it may be something like

$$ 0.0000000000000001_2 \times 2^{-0.000000001_2} $$

(It won't be exactly that, but something like it. In any case the indices "$_2$" indicates that they're binary numbers, not decimal)