javascript - js reads a value in one of the excel columns as 0.3556 but reads 0.35559999999999997?
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?
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:
If the difference between the two numbers a and b is very small, then a can be considered equal to b.
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
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:
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