FALSE and TRUE, (FALSE = -1 ?)

Alan J Rosenthal flaps at dgp.toronto.edu
Wed Sep 12 02:11:34 AEST 1990


alanf at bruce.cs.monash.OZ.AE (Alan Grant Finlay) writes:
>I prefer to use -1 to represent [true] in C.

Assuming you don't modify the compiler, you can't do this consistently as
boolean relations will still return 1.

>Since you can't have a one bit two's complement integer I should probably
>use ~0.

Bad choice, as this will probably count as false on ones complement systems.
(It might not if the compiler can guarantee not to generate you any minus-
zeroes with any operators it provides you.)



More information about the Comp.lang.c mailing list