TRUE and FALSE
Jay A. Konigsberg
jak at sactoh0.SAC.CA.US
Thu Aug 30 08:58:09 AEST 1990
In article <2316 at cirrusl.UUCP> dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
>In <514 at demott.COM> kdq at demott.COM (Kevin D. Quitt) writes:
>>
>>TRUE and FALSE are used for assignment purposes only. It makes
>>the intent of the code more obvious.
>
>When I find somebody who really, really, really wants to define TRUE
>and FALSE, even somebody who uses them for assignment only, I recommend
>the following defines instead:
>
> #define ZERO 0
> #define ONE 1
>
>These are so much more clear than TRUE and FALSE, and if you use
>them in a test, you know exactly what you're testing!
>--
Pish-posh! TRUE and FALSE are much clearer. Kevin is correct when
he says TRUE and FALSE are used for assignment purposes only. The
resulting values are then easly checked in standard C syntax making
the code more self-documentating.
Personally though, I like the following:
#define TRUE -1
Why? Because of the following 8 bit pattern:
1: 01111111
-1: 11111111
I mean, after all, if I'm going to set one I might as well set all :-)
--
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca. UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.
More information about the Comp.lang.c
mailing list