Javascript accuracy

Much has been said on this topic, but I could not find the exact answer to my question.

JavaScript cannot accurately represent decimal numbers, such as 0.1, and this is understandable.

For example, this is true due to rounding errors that occur during animation:

0.1 * 3 === 0.30000000000000004
Run codeHide result

This is good - all in accordance with the IEEE Standard for Floating-Point Arithmetic (IEEE 754).

I don’t understand why other languages ​​that also use the standard give more accurate measurements.

0.1 * 3 === 0.3
Run codeHide result

Is it because of the different rounding rules that they use? https://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules or am I missing something?

+4
1

, IEEE 754 Floating Point, , JavaScript.

, C#, Decimal, , .

JavaScript , BigDecimal, , , + *.

+2

Source: https://habr.com/ru/post/1628638/


All Articles