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



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
.



Relevant Pages

  • Re: value of the constant expression 1<<(1?1:1) < 0x9999
    ... Peter Nilsson writes: ... I'll assume that types int and unsigned int are 16 bits. ... The "usual arithmetic conversions" are applied to the operands ...
    (comp.lang.c)
  • Re: checking array indices
    ... the int value -8388558, converted to unsigned int, yields the value 50. ... The check would fail on the hypothetical exotic system if i is equal ... Keith Thompson kst-u@mib.org ...
    (comp.lang.c)
  • Re: right shifting
    ... It's undefined behavior in both ... Keith Thompson kst-u@xxxxxxx ... If the value of the right operand is negative or is greater than ...
    (comp.lang.c)
  • Re: An overflow case that puzzles me
    ... the operands." ... unsigned integer type is reduced modulo the number that is one greater ... `2026363600u' is a literal constant of type `unsigned int' (under ...
    (comp.lang.c)
  • Re: Question on byteorder operations
    ... Keith Thompson wrote: ... > implementations use any of them. ... by shifting unsigned int ... the broken "Reply" link at the bottom of the article. ...
    (comp.lang.c)