Is there a direct way to turn a negative number into a positive using bitwise operations in ActionScript 3? I just think I read somewhere that this is possible and faster than using Math.abs()or multiplying by -1. Or am I mistaken, and it was a dream after a day's study of bytes and bitwise operations?
What I saw was that bitwise NOTalmost does the trick:
trace( ~(-450) );
If anyone finds this question and is interested in 5 million iterations ~(x) + 1, 50% faster than Math.abs(x).
source
share