FutureBasic Logo

<<    Index    >> FutureBasic 5

not   operator

value = not expr

The not operator interprets expr as an integer, and returns another integer in whose internal bit pattern all the bits are flipped to their opposite state (i.e., all 1's are changed to 0; and all 0's are changed to 1). Coincidentally, because of the way that integers are stored in FutureBasic, the value returned by not expr equals: -(expr + 1).
One common use for not is to reverse the sense of an expression whose value equals _zTrue (-1) or _false (0). Note that (not_zTrue) returns _false, and (not _false) returns _zTrue. You must be careful when using not with "true" values other than -1. For example:
testValue = 35
if testValue then beep 'This produces a beep
if not testValue then beep 'But so does this!
This program produces two beeps, because in the second if statement, "not testValue" produces the value -36, which is still interpreted as "true" by the if statement.
Another common use for not is to help you set or reset individual bits in a bit pattern. For example:
    pattern& = pattern& and not bit(7)
This sets bit 7 in pattern& to zero, and leaves all of pattern&'s other bits alone.

See Also:
and; or; xor