Starting from Scratch (was Re: OT: Modern college educa

From: Eric Smith <eric_at_brouhaha.com>
Date: Sat Oct 24 16:50:46 1998

Sam Ismail <dastar_at_ncal.verio.com> wrote:
> AppleSoft would logically return a +1 for the above statement rather than
> a -1. Why the PET returns a -1 is beyond me. Couldn't they have added
> one more machine instruction to strip off the sign bit?

No, because then it would return 32767, which is even worse.

Remember, in two's complement arithmetic, -1 is all ones. This means that
having predicates return -1 for true is actually useful if you want to use
the return value as a mask for boolean operations on bit fields.

In practice it doesn't really matter; anything non-zero is considered true.
You should really be doing arithmetic on boolean values anyhow. :-)

[Smiley because I've done it many times myself.]

Eric
Received on Sat Oct 24 1998 - 16:50:46 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:31:28 BST