Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!caen!sol.ctr.columbia.edu!ira.uka.de!smurf!ppcnet!ppcger!Sepp From: Sepp@ppcger.ppc.sub.org (Josef Wolf) Newsgroups: comp.lang.c Subject: Re: 0xFF != '\xFF' ? Message-ID: Date: 14 Apr 91 23:00:23 GMT References: <28007837.35A9@marob.uucp> Lines: 21 wolfram@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@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 |