4 ms·
Strangely, clang (but not gcc 7.2) with -O0 generates different code for the two. https://godbolt.org/g/N8mTL6 https://godbolt.org/g/N8mTL6
by cozzyd 9y ago
Strangely, clang (but not gcc 7.2) with -O0 generates different code for the two.
https://godbolt.org/g/N8mTL6 https://godbolt.org/g/N8mTL6
- pkaye 9y agoTry using unsigned int. I believe they are equal only for positive numbers.
- cozzyd 9y agoPerhaps in some strange numbering system but not with two's complement... (to be clear, the return type is cast to bool).
- jerrre 9y agowhy 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.
- cozzyd 9y agoFor some reason gcc is still optimizing it though!