Language
C
Compiler
gcc 13.2.0
Options
Warnings
C11(GNU)
no pedantic
$ gcc prog.c -Wall -Wextra -std=gnu11 When the diff is positive: +1 >> 3 = 0
The rest value: +1 - ((+1 >> 3) << 3) = 1
When the diff is negative: -1 >> 3 = -1
The rest value: -1 - ((-1 >> 3) << 3) = 7
With div instad of >>: +1 / (1 << 3) = 0
The rest value: +1 - ((+1 / (1 << 3)) << 3) = 1
With div instad of >>: -1 / (1 << 3) = 0
The rest value: -1 - ((-1 / (1 << 3)) << 3) = -1
Exit Code:
0