Not, not working
Monkey Forums/Monkey Programming/Not, not working
| ||
Function Main:Int() If Not 1>2 Print "one is not bigger than 2" Else Print "one is bigger than 2" Endif End Function tested in html5 |
| ||
If Not (1>2) |
| ||
Here's my take: It's doing: If ( Not 1 ) > 2 which is If 0 > 2 This fixes it: If Not (1>2) So, could be a bug, depending on what symbol thingy should take precedence... |
| ||
"Not" is an unary operator while <, >, = ... are not. Unary operators always have priority. |
| ||
[monkeycode]If 1 <= 2[/monkeycode] |
| ||
c.k. is right Also note that 'Not' evaluates to a Boolean type. That means you can put any number there you want except zero and the result will always be the same. So really, it's [monkeycode] If Not 1>2 'original If (Not 1) > 2 'unary precedence If false > 2 'NOT forces Boolean If 0 > 2 'Compare operator casts to Int()[/monkeycode] And then the whole thing is optimized out because both sides of the operator are constant expressions. |
| ||
This seems to be the Precedence Table, although the docs don't call it that. Operators within a block have the same precedence, such as + Unary plus - Unary minus ~ Bitwise complement Not Boolean inversewith blocks higher in the table having higher precedence. |