Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!rphroy!caen!uwm.edu!ogicse!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: Hexadecimal/octal constants Message-ID: <1478:Mar2021:59:4991@kramden.acf.nyu.edu> Date: 20 Mar 91 21:59:49 GMT References: Organization: IR Lines: 26 In article rjohnson@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, so that, e.g., the > result of 0xf & 0x2 is 0x2, Yes, the result of 0xf & 0x2 is 0x2. No, C does not ``behave as if it is on a two's complement machine'' for bitwise operations: two's complement has to do with the representation of negatives, and the bit operators basically treat everything as unsigned. (Apparently ANSI implies that any implementation must be one's-complement or two's-complement, but this is beside the point.) C does behave as if it is on a binary machine when it is working with binary digits, even if it is on a base-10 machine or whatever else. > even if the machine representation of > 0xf is 1010 and 0x2 is 0101 [think hypothetical here 8^)]? BEEP! :-) The machine representation is irrelevant. ``If the machine represents 2 as 0101 and 5 as 1010, does 2 + 2 equal 5?'' ---Dan