alanf@bruce.cs.monash.OZ.AU (Alan Grant Finlay) (09/09/90)
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.
flaps@dgp.toronto.edu (Alan J Rosenthal) (09/11/90)
alanf@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.)