0

enter image description here

I would like to know why this number's sum is equal to 0.30000000000000004 ??

Areg Nikoghosyan
  • 449
  • 5
  • 14
  • It's not an issue with JavaScript. It's with binary format. – Pranavan Apr 18 '22 at 11:47
  • I know that this is not an issua. I would like to know why it is ? – Areg Nikoghosyan Apr 18 '22 at 11:48
  • 2
    This is called Floating-Point Anomaly and it refers to the fact that in binary floating-point, only fractional values of the form `i * (1/2)^j` (where i and j are integers) can be represented exactly. So `0.5`, or `0.375`, etc., can be represented exactly but all other decimals, such as `0.2` and `0.3` cannot and when you combine them in various ways, it soon becomes evident that they are only approximate. – RBarryYoung Apr 18 '22 at 11:54

0 Answers0