7
$\begingroup$

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.

$\endgroup$
6
  • 2
    $\begingroup$ Also, most calculators have a different key for $-$ as the subtraction symbol, and $-$ that signifies a number is negative. In this case, you want the negative one. $\endgroup$
    – pjs36
    May 23, 2015 at 23:14
  • 8
    $\begingroup$ This is not a question about mathematics, but about how numbers are handled in a computer/calculator. (The IEE 754 format.) $\endgroup$
    – mrf
    May 23, 2015 at 23:15
  • 8
    $\begingroup$ There's a good question of math here for an eighth grader. In math, that is a perfectly valid real number. What the calculator is saying is that its internal circuitry can't represent that real number. There are many real numbers that computers and calculators can't represent. And the programmers arrogantly say, "That's not a number!" when they SHOULD say: "That's a perfectly good number, we just can't deal with it." $\endgroup$
    – user4894
    May 24, 2015 at 0:07
  • 1
    $\begingroup$ It's also possible that the calculator can represent this number, but it requires you to know a non-obvious sequence of keys to press in order to enter the number correctly. It matters which brand and model number of calculator you're using. $\endgroup$
    – David K
    May 24, 2015 at 0:21
  • $\begingroup$ I've never heard of a calculator that displays "Not a Number." What brand and model number of calculator is this? $\endgroup$
    – JRN
    May 24, 2015 at 6:49

4 Answers 4

13
$\begingroup$

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.

$\endgroup$
3
  • 12
    $\begingroup$ "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." - this isn't an accurate description of what's going on. The problem has nothing to do with memory limitations; it's an issue of what numbers are representable in the calculator's floating-point format, and possibly also an issue of what exactly the OP typed (since NaN is a rather unexpected error result - I'd expect something like 0 or an underflow message). $\endgroup$ May 23, 2015 at 23:44
  • $\begingroup$ Well, when I wrote "a fair bit of memory", I was going to write "a fair bit of memory in the register in which the value was stored", but I didn't want the conversation to get too deep in the weeds. Since the active register in the calculator's floating point format will allow for only so many bits, the given value will exceed those bits and hence is not representable. Or so my understanding goes. I apologize if my approach glossed over too many details. $\endgroup$
    – Ken
    May 24, 2015 at 2:07
  • $\begingroup$ For anyone who reads this: the problem isn't representing this number; the problem is representing a lot of different numbers, this one included. In other words, if the only thing the calculate had to do was represent this number, it would be trivial. But because it has to be able to represent a lot of others as well, many kinds of numbers become different to handle, and this one is one of them. $\endgroup$
    – user541686
    May 24, 2015 at 4:03
4
$\begingroup$

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;
}
$\endgroup$
2
  • 2
    $\begingroup$ One might on the other hand say that it's infinitely larger than zero $\endgroup$ May 23, 2015 at 23:43
  • 6
    $\begingroup$ Never say "never." There are times when an exact comparison is correct, and times when it is not. I'm not sure what this has to do with the main question, though. $\endgroup$
    – David K
    May 24, 2015 at 0:07
0
$\begingroup$

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)

$\endgroup$
-2
$\begingroup$

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.

$\endgroup$
4
  • 2
    $\begingroup$ The exponent appears to be $-308$, that is, the number is very small, not very large. $\endgroup$
    – David K
    May 24, 2015 at 0:05
  • 2
    $\begingroup$ 2.22... to the power of 308 is very different from 2.22... times 10 to the power of 308 which is very different from 2.22... times 10 to the power of -308 $\endgroup$ May 24, 2015 at 0:21
  • $\begingroup$ however, $a \neq b \neq c$ does not mean that $a \neq c$ ;) $\endgroup$ May 24, 2015 at 0:36
  • $\begingroup$ ok sry I seem to have been sleepy, but I think I was onto something as 2.22507e-308 is indeed the smallest number greater than 0 to be representable by a 64 bit floating point number. $\endgroup$ May 24, 2015 at 8:32

Not the answer you're looking for? Browse other questions tagged .