comp.lang.c
[Top] [All Lists]

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

Subject: Re: value of the constant expression 1<<(1?1:1) < 0x9999
From: Peter Nilsson
Date: Tue, 29 Apr 2008 16:13:21 -0700 PDT
Newsgroups: comp.lang.c

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

--
Peter

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy