0xFF != '\xFF' ?

Wolfram Roesler wolfram at cip-s08.informatik.rwth-aachen.de
Fri Apr 12 21:51:02 AEST 1991


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.



More information about the Comp.lang.c mailing list