Not: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(edit)
 
(edit)
Line 1: Line 1:
'''~'''  a.k.a.  '''not''' is usually used in conjunction with an [[If]] [[statement]].
#Redirect:[[~]]
 
Don't use NOT, use ~ because it will work everywhere whereas NOT will only work in If statements
 
 
----
 
 
1) The tilde character is "not" in BR: '~'
If ~1 then print "X" else print "Y"
Y
In my testing, "NOT" only works in an IF statement or a PRINT statement. Whereas "~" works everywhere.
let X=1
let Y=NOT X ! Gives an error
let Y=~X ! Sets y to 0
print NOT Y ! prints 1
print ~X ! prints 0
2) Keep in mind that you can use the unary operator "NOT" in many more places then in an IF-THEN statement. So it couldn't be a parameter of the IF statement.
You can do a comparison and assign the results to a boolean variable (in BR thats just a regular numeric variable that you're calling a boolean variable).
let A=5
let B=7
let TEST = ~(A>B)
IF TEST THEN PRINT "X" ELSE PRINT "Y"
X
You can also print the results of a conditional statement:
PRINT NOT (A>B)
1
PRINT ~(A>B)
1
So, in my testing I have discovered two important things:
1) NOT and ~ do the same thing. But NOT works in only IF and PRINT statements whereas "~" works for IF, PRINT, and LET statements, as well as Function Call Parameters, and many more places.
2) There are lots of different places you can use NOT (~) and all of them are useful.
 
<noinclude>
[[Category:Operators]]
[[Category:Logical Operators]]
</noinclude>

Revision as of 14:28, 9 January 2012

Redirect to: