Share via


Math precision and SSE2 differences

Starting with Windows Internet Explorer 9, math precision in certain edge cases differs from earlier versions. Chakra, the JavaScript engine introduced in Internet Explorer 9 uses Streaming SIMD Extensions 2 (SSE2) if the platform supports them, which results in faster mathematical operations but also yields a difference in precision from the Microsoft JScript engine of Windows Internet Explorer 8

Output from mathematical operations performed by Chakra in Internet Explorer 9 might differ from output from the JScript engine of Internet Explorer 8.

Test your code to ensure that it is not negatively affected by the difference in math precision.

The following example demonstrates the difference:

function test() {
    var x = 6.28318530717958620000;
    var val = Math.sin(x);
    document.write(Math.abs(val)) 
}
test();

In all modes of Internet Explorer 8, this will print "2.4492127076447545e-16". When the platform supports SSE2, in all modes of Internet Explorer 9, this will print "2.4492935982947064e-16".