Home > front end >  3 * 4.8=14.399999999999999 this????????????
3 * 4.8=14.399999999999999 this????????????

Time:10-08

<script>
Document. The write (3 * 4.8)
</script>

The results as follows: 14.399999999999999

Why is this? Don't understand, ask for advice

CodePudding user response:

JavaScript, the precision of the floating-point arithmetic problems
https://www.html.cn/archives/7340

CodePudding user response:

Computer is not necessarily accurate store floating-point
The storage format of floating-point Numbers refer to the following link
https://www.jianshu.com/p/8ee02e9bb57d

CodePudding user response:

Is my CPU is broken

CodePudding user response:

Precision loss...
Py:

Js:

Take 10 again in addition to the first converted to an integer to avoid decimal arithmetic operation
  • Related