News for hackers. Stuff that matters.
Re:Low Level Bit Hacks You Absolutely Must Know by cozzyd on Thursday May 10, 2018 @11:59PM (#17044881)
Strangely, clang (but not gcc 7.2) with -O0 generates different code for the two.

https://godbolt.org/g/N8mTL6

Re:Low Level Bit Hacks You Absolutely Must Know by jerrre on Friday May 11, 2018 @03:26AM (#17045543)
why is this strange? -O0 is no optimization at all, so it isn't strange % yields an integer division right?

On -03 they compile to the same, both signed and unsigned.

Re:Low Level Bit Hacks You Absolutely Must Know by cozzyd on Friday May 11, 2018 @10:10AM (#17047387)
For some reason gcc is still optimizing it though!
Re:Low Level Bit Hacks You Absolutely Must Know by pkaye on Friday May 11, 2018 @01:06AM (#17045082)
Try using unsigned int. I believe they are equal only for positive numbers.
Re:Low Level Bit Hacks You Absolutely Must Know by cozzyd on Friday May 11, 2018 @01:10AM (#17045097)
Perhaps in some strange numbering system but not with two's complement... (to be clear, the return type is cast to bool).