﻿ NOT (Bit-wise complement)
NOT

Syntax

NOT expression
Description

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 literally:
IF NOT condition1 THEN expression1

Is translated as:
IF condition1 = 0   THEN perform expression1

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:
00001111 NOT
-------- equals
11110000

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 5"
'-------- 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.

Example

' Using the NOT operator on a numeric value

numeric_value = 15 '00001111

'Result = -16 =     111111111111111111111111111110000
PRINT NOT numeric_value
END

' Using the NOT operator on conditional expressions

n1 = 15
n2 = 25

IF NOT 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 10"
END

' This will output "Numeric_Value1 is not equal to 10" because
' the 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

• None