Not, at its most primitive level, is a operation, a
logic function that takes one bit and returns a inverted bit. This function
returns true if the bit is false, and false if the bit is true. This also holds
true for conditional expressions in ARMbasic
. When using "Not"
encased in an If block, While loop, or Do loop, the output will behave quite
condition1 THEN expression1
IF condition1 = 0 THEN perform
When given a expression, number, or variable that
return a number that is more than a single bit, Not is performed bit-wise. A
bit-wise operation performs a logic operation for every bit.
The Boolean math
expression below describes this:
Notice how in the resulting number of the operation, reflects an NOT
operation performed on each bit of the expression.
When used with conditions NOT becomes a logical operation.
if NOT x>5
then print "x is less than or equal to
'-------- equivalent to
if x <= 5 then
print "x is less than or equal to 5"
In the above example if x is 7 and you PRINT NOT x>5 would print 0, and
print 1 if x is 3.
If using NOT in a complex statement, it has a very low precedence and it is
best to force the operation of the NOT by using parenthesis.
' Using the NOT operator on a numeric
numeric_value = 15 '00001111
'Result = -16 =
' Using the NOT operator on conditional
n1 = 15
n2 = 25
n1 = 10 THEN PRINT "N1 is not equal to 10"
IF NOT n2 = 25 THEN PRINT
"N2 is not equal to 25"
IF (NOT n2 = 25) or
n2=10 THEN PRINT
"N2 is not equal to 25 or is equal to
' This will output
"Numeric_Value1 is not equal to 10" because
first IF statement is false.
' It will not output the
result of the second IF statement because the
condition is true.
Differences from other BASICs