Bartek Szopka: Everything you never wanted to know about JavaScript numbers -- JSConf EU 2013
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions about floating-point surprises and rounding errors, since it explains the bit-level reason behind them in a way anyone can follow.
Recommended by 3 people across 3 different months, 2010 to 2015.
What it is
Bartek Szopka's JSConf EU 2013 talk explains how JavaScript numbers are stored as IEEE 754 double-precision 64-bit values. He walks through the bit layout and answers questions such as why 0.1 is not exact, what Infinity looks like in binary, and why there are two zeros, using an interactive visualization.
What people said
Strong rec Mörre · 2013-11 · Stack Overflow · on “Is floating-point math broken?”
Here is a VERY well-done and deep (bit-level) but comprehensible 30min video from JSconf EU 2013 about numbers in Javascript. JS number implementation is according to IEEE 754 standard, so not JS specific. Video link: [this video]
Strong rec Mörre · 2013-11 · Stack Overflow · on “javascript alert giving different number”
Watch this talk, it will tell you all you ever need to know about IEEE 754 number implementations. A MUST WATCH for programmers, really: Bartek Szopka: Everything you never wanted to know about JavaScript numbers -- JSConf EU 2013; [this video]
Strong rec Mörre · 2013-11 · Stack Overflow · on “Number.isNaN('asd') === false in Node.js! What gives?”
As an aside, I highly recommend this great JSConf talk - " Everything you never wanted to know about JavaScript numbers -- JSConf EU 2013" [this video] It explains the low-level (Bit-level) details of how "Number" is implemented in JS but in a way that anyone can understand it.
Recommends Bob Fanger · 2010-02 · Stack Overflow · on “PHP rounding problem (5.2.3)?”
Floats are evil. Quoting the PHP manual documentation on Floating Point numbers [LINK] : So never trust floating number results to the last digit, and never compare floating point numbers for equality. If higher precision is necessary, the arbitrary precision math functions [LINK] and gmp [LINK] functions are available. If you want to know why and how floats work I recommend watching: Everything you didn't want to know about JavaScript numbers [this video]
Recommends lmenus · 2015-08 · Stack Overflow · on “Why does this happen to numbers in JavaScript”
As mentioned above, JavaScript uses the double-precision 64-bit floating point format [LINK] for the numbers. 52 bits are reserved for the values, 11 bits for the exponent and 1 bit for the plus/minus sign. The whole deal with the numbers is beautifully explained in this video [this video] . Essentially, JavaScript uses a pointer that moves along the 52 bits to mark the floating point. Naturally, you need more bits to express larger numbers such as your 111111111111111111. To convert your number into the binary, it would be sign - 0 exponent - 10000110111 mantissa - 1000101010111110111101111000010001100000011100011100 The more space is taken by the value, the less is available for the decimal dig