Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!sdcsvax!ucsdhub!esosun!seismo!uunet!microsoft!w-colinp From: w-colinp@microsoft.UUCP (Colin Plumb) Newsgroups: comp.lang.c Subject: Re: value of TRUE??? Message-ID: <825@microsoft.UUCP> Date: 7 Mar 89 20:10:13 GMT References: <987@infmx.UUCP> Reply-To: w-colinp@microsoft.uucp (Colin Plumb) Distribution: usa Organization: very little Lines: 20 Sigh, this went around a few short weeks ago... When a C operator returns a truth value (these operators are ==, !=, <, > , <=, >=, !, &&, || and defined()), the result is of type int and has the value 0 (for false) or 1 (for true). When a C operator takes a truth value (!, &&, ||, ? :, if(), if() else, while(), do while(), and for(;;), and #if), the value must be comparable to 0 (i.e. int, float, pointer, etc.) and if it is non-zero, it is considered to be true. An if() statement does not return a value, so I don't quite understand that part of the original question. if(i=3)... is equivalent to i=3; if(i)... (assuming i isn't a macro). If i is 2 bits or wider, this is equivalent to i=3; if(3)... which is equivalent to i=3; if(1)... (or if(0.0001)... or if(&i)... or if(-1)...). -- -Colin (uunet!microsoft!w-colinp) "Don't listen to me. I never do." - The Doctor