NOT command


Senior Member
This may be a silly question.. Is there a way to express NOT > value or NOT < value?
I'm aware of <> or != the value.
However, I couldn't find a variation for - NOT greater than or NOT less than the value.

My application (M2) requires a NOT, due to ADC read fluctuations that can't be overcome by averaging, because of timing constraints.
Last edited:


Senior Member
My application (M2) requires a NOT, due to ADC read fluctuations ..
Of itself, a NOT cannot change the testing range. As said, a ">" is the inverse of "<=" or vice versa. Or the IF ..THEN {GOTO} label : .... : label: syntax performs the "opposite" of the IF .. THEN : ..... : ENDIF structure.

Do you actually want: IF ( < value) OR (> differentvalue) , i.e. to code a "nearly equal to" ? Note also that the use of OR or AND are generally interchangeable by the use of NOT(s). The efficiency of coding that depends if "value" is a variable or a constant (i.e. known at the time of coding); in the latter case you can pre-calculate the "acceptance range" (i.e. in the compiler, not by the program). Or a useful trick for the "nearly equals" test is to subtract, for example, (value - 1) from the measured-value (which may or may not underflow to a large positive value) and then use an IF ... > 2 (or <= 2 , etc.). You haven't said if you're (already) using READADC10 or just READADC.

Cheers, Alan.


Senior Member
Thanks for the reply guys. It has straightened up my slow thinking this morning (y) I was thinking a NOT would work better... but it maybe not needed.


Senior Member
You misunderstand the NOT operator.
When you say "not less than" that is an english expression and those of us that speak english will understand what you mean.

However the PICAXE BASIC operator NOT is a mathematical operator with a specific mathematical definition.
It is defined in the section "Variables - Unary Mathematics" of the manual as:
The NOT function inverts a value.
e.g let b1 = NOT %01110000 (answer b1 = %10001111)
i.e. the PICAXE BASIC operator NOT only makes a mathematical alteration of a number.

The less than "<" and "greater than ">" symbols are conditions that can be used as a part of the BASIC tests that compare the contents of a variable against a constant, like in the IF statements.
and this is the set of the allowable conditions from the manual for the statement "if...then \ elseif...then \ else \ endif":
?? can be any of the following conditions
= equal to
is equal to
<> not equal to
!= not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to
The less than "<" and "greater than ">" symbols are not numbers and so it makes no sense to code "NOT >" or "NOT <".

As lbenson described in post #2, the test condition ">=" is the PICAXE BASIC equivalent to the english statement "not less thsn" and "<=" the equivalent of the english statement "not greater than".


As Flenser has stated, the PICAXE NOT command is a bitwise math calculation
For example
b0 = %00100001 ; = decimal 33
b1 = NOT b0
the result is %11011110 = decimal 222

The NOT command is available across the M2 and X1/X2 parts whereas INV (also bit wise compliment) is only available for the X1/X2 parts