Shop OBEX P1 Docs P2 Docs Learn Events
true equals -1? - Page 2 — Parallax Forums

true equals -1?

2»

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-07-06 05:05
    localroger said...
    There is no case in Spin where ==false and ==true are both false.
    Actually, 5 == false and 5 == true are both false in Spin, since they're the same as 5 == 0 and 5 == -1, respectively. "<> 0" is the universal promoter to a Boolean truth value from a numeric one.

    Having true be equal to -1 has a singular advantage in a processor without a single-cycle multiply, since you can combine Boolean expressions with arithmetic expressions using the much quicker bitwise and (&).

    -Phil
Sign In or Register to comment.