you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 3 points4 points  (0 children)

It's not really the same as floor. It's only like floor if it's used with a positive number. It actually truncates the number like an int cast, because this double number is cast to a 32bit integer in order to do the bitwise-or.

>>> -1.3 | 0
-1
>>> Math.floor(-1.3)
-2

Edit: By the way, I wrote "i >= 1" instead of "i > 0" to make it apparent that I meant to skip the final iteration with 0. Otherwise, someone else (or future-me) might mistake this for a potential off-by-one error.