Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!husc6!cmcl2!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: comp.lang.c
Subject: Re: Defining TRUE and FALSE
Message-ID: <6094@brl-smoke.ARPA>
Date: Thu, 9-Jul-87 21:12:42 EDT
Article-I.D.: brl-smok.6094
Posted: Thu Jul  9 21:12:42 1987
Date-Received: Sun, 12-Jul-87 07:16:38 EDT
References: <13851@watmath.UUCP>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 34
Keywords: boolean, true, false

In article <13851@watmath.UUCP> jyegiguere@watmath.waterloo.edu (Eric Giguere) writes:
>          #define TRUE   ( 0 == 0 )
>          #define FALSE  ( 1 == 0 )
>The point here is that instead of letting the program arbitrarily
>decide what TRUE and FALSE should be, we let the compiler decide,
>which adds to the portability.

You're under a misconception; nothing whatever is gained by this.
See my next comment.

>In actual effect, the definition for FALSE above could just as well
>be replaced with
>          #define FALSE   0

Furthermore, you might have well written
	#define	TRUE	1
since (1 == 0) has precisely the value 1 in C.

In C expression evaluation, relationals and other nominally Boolean
operators produce either 0 or 1 for their value -- never anything
else.  In any context where the "truth" of an expression is being
tested (for example in an "if" condition), any non-zero expression
is considered to be "true" and only zero is considered "false";
thus testing for truth works with a superset of the values produced
by expressions that compute truth values.  All this is built into
the rules of the C language and is NOT up to the implementation.

I for one wish C had been designed with an explicit Boolean data
type distinct from integral types, but it wasn't.  I do find it
helpful to maintain the conceptual distinction in one's code,
however, never using an arithmetic expression where a relational
test (against 0) is called for, and never performing arithmetic on
conceptually Boolean data.  ("What, never?"  "No, never!"  "What,
never?!"  "Well, hardly ever!")