0xFF != '\xFF' ?

Josef Wolf Sepp at ppcger.ppc.sub.org
Mon Apr 15 09:00:23 AEST 1991


wolfram at cip-s08.informatik.rwth-aachen.de (Wolfram Roesler) writes:
] It's best to compare in the following way:
] 	char x = -1;
] 	char y = 0xff;
] 	if ((unsigned char)x = (unsigned char)y)
] 	  ...
] ... so before comparing, cast both to unsigned char. This because you
] do not know (because it's undefined by the language definition) if char
] is unsigned or not.

You even don't know about the number of bits of a char (or is it defined?)
So you can get into trouble with this.

Greetings
    Sepp

| Josef Wolf, Germersheim, Germany | +49 7274 8047  -24 Hours- (call me :-) |
|     sepp at ppcger.ppc.sub.org      | +49 7274 8048  -24 Hours-              |
| ...!ira.uka.de!smurf!ppcger!sepp | +49 7274 8967  18:00-8:00, Sa + Su 24h |
| ----=> kommt Zeit => kommt Frau  | all lines  300/1200/2400 bps 8n1       |
|  kommt Frau => geht Zeit, geht Zeit => geht Frau, geht Frau => kommt Zeit |



More information about the Comp.lang.c mailing list