Hexadecimal/octal constants

Doug Gwyn gwyn at smoke.brl.mil
Thu Mar 21 07:51:05 AEST 1991


In article <RJOHNSON.91Mar20091144 at olorin.shell.com> rjohnson at shell.com (Roy Johnson) writes:
>Is it true on every platform that 0xf == 15?

Yes.

>Is it also true on every platform that for bitwise operations, C
>behaves as if it is on a two's complement machine, ...

No.

>... so that, e.g., the
>result of 0xf & 0x2 is 0x2, even if the machine representation of
>0xf is 1010 and 0x2 is 0101 [think hypothetical here 8^)]?

The bitwise operations are carefully specified in the C standard
to have the "right" properties.  However, twos complement has
nothing to do with this.



More information about the Comp.lang.c mailing list