I realize you could divide the number by its absolute value and that results in a 1 or -1. Is there a computationally cheaper way to isolate the sign? Like maybe could you use getbit() in the most significant bit? (I'm guessing that's where the sign of an int is stored). Or maybe is a condition in C2 that tests for > or < zero faster than division?
0 with ? : should be fine.
newt is right, use ternary operators like: (value < 0 ? -value : value ) if you want.
...but, your question have reason - bit operations more faster.
Develop games in your browser. Powerful, performant & highly capable.
newt Kurz So it sounds like >,<,etc is faster than division, and getbit() is faster than both? If I got that right, which bit is the sign?
I don't think you can use the getbit on that regard, but normally it is the highest bit
And performance wise, the difference won't be noticeable anyway