"David Fisher" <no****@nospam.nospam.nospam> wrote in message
news:do******************@nasal.pacific.net.au...
"jeffc" <no****@nowhere.com> wrote:
But the bits for 1 are 01, and for 2 are 10. When you AND them
together, there aren't any ones. Did you mean OR?
The bit patterns for 1 and 2 are not absolutely guaranteed to be
"000...01" and "000...10" - the "two's complement" format represents them this way,
..
Actually, it has nothing to do with two's complement. The C standard
REQUIRES
the positive numbers to be simply straight forward binary. The rules (for
C++ and
C89) say that unsigned values are pretty much straight forward binary and
that the
positive signed variables have the same representation as their unsigned
counterparts.
The C99 standard goes even further and says that there is only three legal
integer
encodings: 2's complement, 1's complement, and signed-magnitude. All of
which
obey the earlier constraint.
-> 0x1 and 0x2 ought to be pretty safe, though ...
This is a pretty bizarre statement give your earlier statement. 1 and 0x1
are
exactly the same value as var as the language is concerned (the hex
specified
numbers only differ in that they will have type unsigned int if int can't
represent them).