javascript - js reads a value in one of the excel columns as 0.3556 but reads 0.35559999999999997?
PHP中文网
PHP中文网 2017-07-05 11:01:05
0
3
1142

js reads a value in one of the excel columns as 0.3556, but the read value is 0.35559999999999997. But if you delete 0.3556 manually and write it in manually, it will be fine. Why is this?

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
曾经蜡笔没有小新

You can directly enter 0.3556 and it will be normal. This may be a good thing. Microsoft has rounded up 0.35559999999999997 and displayed it as 0.3556.


Microsoft may be based on the following considerations:

  1. If the difference between the two numbers a and b is very small, then a can be considered equal to b.

  2. It doesn’t look good when there are many decimals

phpcn_u1582

I remember there is a setting in Excel that allows you to specify the number of decimal places for a cell. It may be that this setting hides the subsequent digits.

女神的闺蜜爱上我

It is estimated that in excel, this column of numbers has a higher precision, and it may be of long type. JS indicates that there is a problem with long type numbers

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template