Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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?
Develop games in your browser. Powerful, performant & highly capable.
0 with ? : should be fine.
https://www.scirra.com/blog/83/optimisa ... -your-time
newt is right, use ternary operators like: (value < 0 ? -value : value ) if you want.
...but, your question have reason - bit operations more faster.
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