Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site chinet.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!chinet!rlk From: rlk@chinet.UUCP (Richard L. Klappal) Newsgroups: net.lang.c Subject: Re: Cryptic C Message-ID: <156@chinet.UUCP> Date: Sun, 25-Aug-85 04:38:34 EDT Article-I.D.: chinet.156 Posted: Sun Aug 25 04:38:34 1985 Date-Received: Mon, 26-Aug-85 01:25:19 EDT References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> <2076@ukma.UUCP> <685@gitpyr.UUCP> Reply-To: rlk@chinet.UUCP (Richard L. Klappal) Organization: chinet, Public Access UN*X, Chicago Lines: 52 Summary: In article <685@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes: >In article <2076@ukma.UUCP>, david@ukma.UUCP (David Herron, NPR Lover) writes: >> In article <675@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes: >> > >> > ... I personally prefer: >> > >> > #define TRUE 1 >> > #define FALSE 0 >> > typedef char bool; >> >> Well, I personally prefer: >> >> #define TRUE (1==1) >> #define FALSE (1==0) >> typedef char bool; >> >> Which is succint, to the point, and *machine*independant*! >> > >Oh? On what machine is (1==1) equal to 0, or (1==0) not equal to 0? In >section 7.6 (Relational operators, Appendix A - C Reference Manual from >K&R's The C Programming Language), it explicitly states that the logical >operators all yield 0 if the relation is false and 1 if the relation is >true. Nothing is mentioned about possible variations due to implementation >machine differences. > > robert >-- >Robert Viduya 01111000 Maybe not 'machine independent' in C, but the logic will be 'language independent' (using the appropriate equality operator). I've had to debug an awful lot of assembly language where a cpu 'Z' flag (zero-flag) was used as TRUE. About like strcmp returns 0 if two strings are the same so that you cannot extend the concept if (string1==string2) {...} that works in F77, PL/I, BASIC, etc. Richard Klappal UUCP: ..!ihnp4!chinet!uklpl!rlk | "Money is truthful. If a man MCIMail: rklappal | speaks of his honor, make him Compuserve: 74106,1021 | pay cash." USPS: 1 S 299 Danby Street | Villa Park IL 60181 | Lazarus Long TEL: (312) 620-4988 | (aka R. Heinlein) -------------------------------------------------------------------------