Solution for Floating-Point Problems in JavaScript

So you’ve written some absurdly simple JavaScript code, say for example: 0.1 + 0.2 and got a really unexpected result: 0.30000000000000004 instead of 0.3 Why does it happen? In fact, all numbers in JavaScript are double-precision floating-point numbers, which are 64-bit encoding of numbers specified by the IEEE 754 standard.…