No Such Thing (errata)

darryl at ISM780.UUCP darryl at ISM780.UUCP
Fri Aug 30 22:38:00 AEST 1985


>To me, the mapping TRUE -> 0 and FALSE -> non-zero doesn't seem obvious,

That's probably because you have it turned around... TRUE -> nonzero,
FALSE -> 0.

>In assembler, one often writes the following (I'm using pseudocode
>rather than any particular assembler):
>
>        compare two values
>        jumpto stuff  if zero
>
>Which is the assembler equivalent of
>
>        if (value1 == value2)
>          <do stuff> ;

Once again, you seemed slightly confused...  These two don't exactly match
each other.  In assembler, you probably jump around the <do stuff> code.
If you do, then you want to jump on nonzero, assuming the C code is what
you really wanted.  In any event, C's approach is very assembler-like;
any conditional has an implicit comparison against zero, just like most
machines support.

>When I was in high school I was programming TRS-80's in both assembler
>and BASIC, and I had lots of trouble remembering whether BASIC
>represented truth as zero or -1.  No such memory is needed for the
>assembler, of course, since comparison is merely done by subtraction (a
>compare instruction is usually just a subtract instruction that doesn't
>store the result anywhere), so it is obvious what the zero indicator
>means.  It is not so obvious to me that in C 0 should mean false and 1
>mean true.

If you don't feel comfortable with a language, use another or spend the
time and effort to become comfortable.  C is certainly not my choice for
a beauty contest, but one can craft large, useful programs that can
then be run, reasonably efficiently, on many machines.  I suppose that
there is some beauty to that, after all.

	    --Darryl Richman, INTERACTIVE Systems Corp.
	    ...!cca!ima!ism780!darryl
	    The views expressed above are my opinions only.



More information about the Comp.lang.c mailing list