I\'m using Math.ceil( Math.abs( x ) ) inside a loop.
Math.ceil( Math.abs( x ) )
Can anyone realize any optimization for this operation? (Bitwise or what?)
You are welcom
x < 0 ? Math.ceil(-x) : Math.ceil(x) produces a 40% speedup in Firefox 3.6 (little difference in the others) while remaining relatively readable.
x < 0 ? Math.ceil(-x) : Math.ceil(x)
Here is the jsPerf page. Ignore the "some bitwise operators" label; the expression above doesn't use any.