I found there is no precision loss with IE10, which is common in other browsers like Edge, Chrome, Firefox. I'd like to know about is there any compatible workaround in IE10?
Asked
Active
Viewed 106 times
3
-
1Sounds like IE10 is not compliant with the official specification (not surprising by itself!) – CertainPerformance Nov 04 '19 at 06:06
-
I would like to know that JS engine of IE 10 (Chakra) uses the IEEE 754 floating-point format for number representation? If IEEE 754 is used then they should give a response like all other browser engines like V8. – Akshay Bande Nov 04 '19 at 06:41
-
1The console might just be rounding off the number to fewer decimal places than other browsers. What do you see if you do `0.1 + 0.2 == 0.3`? – Barmar Nov 04 '19 at 07:40
-
@Barmar Good, return `false` when input `0.1 + 0.2 == 0.3`. it is just a browser console tricky. :-) – licaomeng Nov 04 '19 at 12:10
1 Answers
0
Try to clear the browser data (cache and history), then recheck it.
I have tested it on my machine, all of the browsers (include IE 9+, Microsoft Edge, Chrome and Firefox) will display the same result 0.30000000000000004
, this is a Floating-Point Arithmetic issue, you could check this article and this thread.
To solve the floating point arithmetic issue, we could use the following methods:
please refer to the following code:
var x = 0.2 + 0.1; document.getElementById("demo1").innerHTML = "0.2 + 0.1 = " + x; var y = (0.2*10 + 0.1*10) / 10; document.getElementById("demo2").innerHTML = "0.2 + 0.1 = " + y;
The output as below:
0.2 + 0.1 = 0.30000000000000004 0.2 + 0.1 = 0.3
using the toFixed method.
var x = 0.1; var y = 0.2; console.log((x + y).toFixed(1));
The result is :
0.3

Zhi Lv
- 18,845
- 1
- 19
- 30
-
IE version: 10.0.9200.17457; IE update version: 10.0.30 (KB3078071); This version could reproduce it. – licaomeng Nov 04 '19 at 09:21
-
The output like [this](https://i.stack.imgur.com/wsxWa.png). Try to use (x + y).toFixed(18). If still not working, try to reset the browser setting or reinstall the browser, besides, you could also try to upgrade the IE browser version to the latest version. – Zhi Lv Nov 04 '19 at 13:17