Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • How it convert the operands to 32 bit integers? Commented Feb 27, 2012 at 22:02
  • 1
    @Shiplu: It's defined in the specification: es5.github.com/#x9.5 (which does not mean that browsers really do it that way). Commented Feb 27, 2012 at 22:03
  • @Shiplu i'm not exactly sure how it does that. Likely converts them first to numbers and then rounds to 32 bit integers. Commented Feb 27, 2012 at 22:03
  • 2
    @Shiplu: Yes, it converts it to a 32-bit integer (es5.github.com/#x9.5) -- temporarily, for the calculation. Then the 32-bit integer is converted back to an IEEE 64-bit float (the only kind of numbers that JavaScript has, except for temporary integers during calculations like this one), but at that point the fractional part has been removed (e.g., Math.floor). Commented Feb 27, 2012 at 22:11
  • Thanks for the explanation. I also though the result is float. Commented Feb 27, 2012 at 22:46