| | |
Summary: 1
Binghamton University
Integer
C
Puzzles
· x < 0 ((x*2) < 0) no (overflow)
· ux >= 0 yes (casting to unsigned)
· x & 7 == 7 (x<<30) < 0 (yes)
· ux > -1 (no, casting to unsigned)
· x > y -x < -y (no, Tmin)
· x * x >= 0 (no overflow)
· x > 0 && y > 0 x + y > 0 (no overflow)
· x >= 0 -x <= 0 (yes)
· x <= 0 -x >= 0 (no, Tmin)
· (x|-x)>>31 == -1 (no, zero)
· ux >> 3 == ux/8 (yes)
· x >> 3 == x/8 (no, sign extend means no zero)
· x & (x-1) != 0 (no, power of two numbers fail)
int
x
=
foo();
int
y
=
bar();
unsigned
ux
=
x;
unsigned
uy
=
y;
|