Skip to main content
gamedev.net
🔒 Locked

[web] Is JavaScript floating-point math deterministic?

Started by Gamer Gamester Aug 30, 2011 at 6:45 AM 0 replies 2.8k views
Original Post
Gamer Gamester
Gamer Gamester
Is JavaScript floating-point math deterministic across modern browsers and OSes?

I haven't been able to find much info on this... though I'm getting the impression that the answer is an unfortunate "no".
Hodgman
Hodgman
According to the spec, they seem to dictate compliance with IEEE 754, which should give the usual determinism caveats...
The Number type has ... values, representing the double precision 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic...
This procedure corresponds exactly to the behaviour of the IEEE 754 ?"round to nearest" mode...
The result of a floating-point multiplication is governed by the rules of IEEE 754 binary double-precision arithmetic... The result of division is determined by the specification of IEEE 754 arithmetic...
etc...[/quote]...but, then again, when did browsers ever faithfully implement common specifications? wink.gif
You can see the list of dialects and the version of the spec they purport to implement on wikipedia.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.