I want to get the values of INT_MIN
and INT_MAX
. I\'ve tried ~0
and ~0 >> 1
since the leftmost bit is a sign bit bu
numbers are stored in 2's compliment so ~0
is 0XFFFFFFFF
which is -1 .
so FFFFFFF(1111) >>1
gives (1111)FFFFFFF
= 0XFFFFFFFF
= -1
.
When shifting an unsigned
value, the >>
operator in C is a logical shift
. When shifting a signed
value, the >>
operator is an arithmetic shift
.
So , ~0U >> 1
gives (1111)FFFFFFF
= 0XFFFFFFFF
.