Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site sdcsvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!ittatc!dcdwest!sdcsvax!hutch From: hutch@sdcsvax.UUCP (Jim Hutchison) Newsgroups: net.lang.c Subject: Re: Boolean Operators Slighted in C Message-ID: <1776@sdcsvax.UUCP> Date: Mon, 12-May-86 13:42:09 EDT Article-I.D.: sdcsvax.1776 Posted: Mon May 12 13:42:09 1986 Date-Received: Wed, 14-May-86 22:08:26 EDT References: <838@ihwpt.UUCP> <778@bentley.UUCP> Reply-To: hutch@sdcsvax.UUCP (Jim Hutchison) Organization: UCSD EMU Project (Educational Microcomputer Unix) Lines: 31 () well now for ||= you can use |= because C defines 0 as false and non-0 as true (Yes, I know that boolean expressions are defined to return 0/1 as defined in K&R if that is still used). typedef char bool; #define B_TRUE ((bool)1) #define B_FALSE ((bool)0) bool a, b; a = B_TRUE; b = (x == READY); ... b |= (x == READY); b ^= a; Now this can get you into trouble, because 2 and 1 and 47 are also "true". This is o.k. for '|' but not '^'. You could of course do b = (b == 0) ^ (a == 0) but that looks a bit strained. -- /* Jim Hutchison UUCP: {dcdwest,ucbvax}!sdcsvax!hutch ARPA: Hutch@sdcsvax.ucsd.edu [ Disclaimer eaten by a passing kiwi ] */