Re: value of the constant expression 1<<(1?1:1) < 0x9999



Peter Nilsson <airia@xxxxxxxxxxx> writes:
Keith Thompson wrote:
...
I'll assume that types int and unsigned int are 16 bits.

1<<(1?1:1) has the value 2 and is of type int.

0x9999 has the value 39321 and is of type unsigned int.

The "usual arithmetic conversions" are applied to the operands
of "<". This converts the left operand, 2, from int to unsigned int.

So the expression 1<<(1?1:1) < 0x9999 is equivalent to
1U < 39321U,

ITYM: 2U < 39321U

Yes, thanks.

--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages