JavaScript Numbers
The title for this post might sound vague, but the reason I’m writing it is because in JavaScript this is true:
1
(.1 + .2) !== .3;
This makes my head explode so I want to understand better the reason for this.
IEEE 754
It turns out that JavaScript only has one number type, unlike other programming languages that have many types(int, long, float, etc…). The type JavaScript uses is defined by the IEEE 754 standard for floating point numbers. This format is good because many hardware manufacturers ship they chips with support for this standard which makes operations on these numbers really fast.