FALSE and TRUE, (FALSE = -1 ?)

Alan Grant Finlay alanf at bruce.cs.monash.OZ.AU
Sun Sep 9 15:02:41 AEST 1990


I prefer to use -1 to represent false in C.  This uses redundancy to decrease
the chance of an error when more than one bit is used.  Since you can't have
a one bit two's complement integer I should probably use ~0.

The ! operator in C is designed to allow either 1 or -1 as representing false.
It looks as though I am a minority voice but this certainly means performing
a<b tests for "booleans" is not a safe practice in C.  



More information about the Comp.lang.c mailing list