1

The value of Number.MAX_VALUE is the largest positive finite value of the Number type, which is approximately 1.7976931348623157 × 10308.

Source

Why "approximately"? Can we not know for sure that this is indeed the maximum positive numeric value? The answers in this question seem to prove this quite well. Or does approximate mean something different in this context?

Community
  • 1
  • 1
timonsku
  • 1,249
  • 2
  • 21
  • 45
  • 3
    Do you really want to type a 300+ digit long number? – Niet the Dark Absol Jun 06 '14 at 13:13
  • 2
    Do you really want to **read** a 300+ digit long number? – Quentin Jun 06 '14 at 13:16
  • Well the word approximately to me means it's not exact it comes close but its not exact, meaning 1.7976931348623157 × 10^308 written out wouldn't be certainly equal to the maximum possible positive value. Mind that english isn't my native language, maybe my definition is simply wrong. – timonsku Jun 06 '14 at 13:34

2 Answers2

6

The exact value of MAX_VALUE is:

179,769,313,486,231,570,814,527,423,731,704,356,798,070,567,525,
844,996,598,917,476,803,157,260,780,028,538,760,589,558,632,766,
878,171,540,458,953,514,382,464,234,321,326,889,464,182,768,467,
546,703,537,516,986,049,910,576,551,282,076,245,490,090,389,328,
944,075,868,508,455,133,942,304,583,236,903,222,948,165,808,559,
332,123,348,274,797,826,204,144,723,168,738,177,180,919,299,881,
250,404,026,184,124,858,368

Does this mean anything more to you than "approximately 1.7976931348623157 × 10308"?

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • I would love to know how you got that number :-) – thefourtheye Jun 06 '14 at 13:23
  • 1
    @thefourtheye Certainly =3 I double-checked the format for double-precision floats, then quickly generated a string with the appropriate number of `1`s that is the maximum value of the mantissa, concatenated with the correct number of `0`s for the maximum exponent. I then shoved the result in [this bignum decbin calculator](http://www.exploringbinary.com/binary-converter/) and double-checked again to ensure it matched the scientific notation in the specification :) – Niet the Dark Absol Jun 06 '14 at 13:24
  • Well the word approximately to me means it's not exact it comes close but its not exact, meaning 1.7976931348623157 × 10^308 written out wouldn't be certainly equal to the maximum possible positive value. – timonsku Jun 06 '14 at 13:33
  • 2
    Scientific notation is an approximation of the real value. Therefore, unless the value happens to stop there, it is approximately equal to the scientific notation. The exact value, which I have given, is... exact. – Niet the Dark Absol Jun 06 '14 at 13:35
  • But >why< is it approximately equal and not exact as the written result? Is this just terminology because it doesn't represent the result but a shorter form of it in form of an equation? – timonsku Jun 06 '14 at 18:57
  • 1
    @ProfessorFartSparkle Yes. Exactly that. A 309-digit long number has no meaning. When you see `1.7976931348623157 × 10^308` you know instantly that it's a huge number. – Niet the Dark Absol Jun 06 '14 at 19:03
3

First, you would not want to write a number with 308 digits. There are probably further numbers after the coma, which are not written, and this is the reason it is an approximation.

Second, the Number object can not take all the values between 0 and 1.7976931348623157 × 10^308. It can take all the values between +- 0 and 2^53. For bigger values, it stores a number smaller than 2^53 and an order of magnitude. So you cannot have unit precision, unless the number you want to store happens to be exactly of the form x * 2^e.

Still the biggest number you can store is precisely (2^53 - 1) * 2^971, which approximately equals 1.7976931348623157 * 10^308, which is much easier to read.

(So, get me right, "First" is the real reason, and "Second" is just an explanation of what is the exact value.)

Source : http://www.ecma-international.org/ecma-262/5.1/#sec-8.5

jillro
  • 4,456
  • 2
  • 20
  • 26
  • Thanks, that makes total sense. The terminology just confused me when talking about a specific number. – timonsku Jun 06 '14 at 13:36
  • You are missing a zero in (2^53 - 1) * 2^970. And it is actually (2^54 - 1) * 2^970, as 1.11..11 with 53 binary places after the dot is 2-2^(-53)=(2^54-1)*2^(-53). – Lutz Lehmann Jun 06 '14 at 14:10