At 3/23/16 06:26 PM, MSGhero wrote: on js to
return n > 0 ? n|0 : (n-1)|0;
That obviously doesn't deal with NaN, inf, floats bigger than MAX_SIGNED_INT, and probably other things. But yeah, 20x faster than Math.floor. But it's not nearly as dramatic of a speedup on the other targets, 2x faster on flash, a little bit on cpp, and worse on neko for some ghastly reason.
That clever version using just bitshifts in my edit will most likely be faster than that. (And might even be a bit faster with the redundant > 0 at the end removed, which, so far as I can tell, is just there to make the result an actual boolean for true cases.)
But, at the end of the day: it's JavaScript. If you need that kind of performance, you're writing the wrong language.