No Such Thing

Barry Margolin barmar at mit-eddie.UUCP
Tue Aug 27 17:45:57 AEST 1985


To me, the mapping TRUE -> 0 and FALSE -> non-zero doesn't seem obvious,
and I'm sure it isn't to most programmers who ever worked in assembler.
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> ;

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.
-- 
    Barry Margolin
    ARPA: barmar at MIT-Multics
    UUCP: ..!genrad!mit-eddie!barmar



More information about the Comp.lang.c mailing list