~
Jump to navigation
Jump to search
The logical unary negation operator ~ reverses the meaning of its operand. The operand must be numeric. Note that in BR, 1 means true and 0 means false.
The ~ operator works as follows:
- The result is true if the operand is false
- The result is false if the operand is true.
The effect of the ~ operator is equivalent to the NOT operator, with one difference: ~ works everywhere whereas NOT will only work in If and PRINT statements.
~ is normally used in conjunction with an IF Statement.
The following examples demonstrates the use of ~:
00010 let x = 1 ! 1 is same as true 00020 let y = ~x ! not true evaluates to false, which is 0 in BR
00010 let result = ~( 2 > 5 ) ! 2 > 5 evaluates to false, so ~( 2 > 5 ) evaluates to true, which is 1 in BR 00020 print result ! since result is 1, that's what will print on the screen