Not
BlitzMax Forums/BlitzMax Programming/Not
| ||
This command is begging to cause a bug in your code... Strict Local b=0 If Not b=4 Then Print "this is not printed" If Not (b=4) Then Print "this is printed" |
| ||
The expression "Not 0" has a value of "-1", so as -1 is not equal to 4 there's no bug here. "Not" has a higher operation order than a comparison (I *think* most unary operators have 'preference' over binary ones) |
| ||
It would be better to use "<>". |
| ||
That's something you have to get used to. I've been annoyed by this for times, but still havn't learnt my lesson. :) |
| ||
Yeah the only time I use not is for things like checking whether some is defined, or has a value at all. |
| ||
Misuse of this command is begging to cause a bug in your code. |
| ||
It makes sense to me. When you put (b=4) in brackets, this is evaluated in a boolean kind of way, ie is b 4? no, =false, and then `not false` is the same thing as `is true`, thus it prints. Just think what: If Not ~(b=4) then Print "yes" would do. :-D .... it won't print, since (b=4) is false, which has a value of 0, and then ~0 produces $FFFFFFFF, then Not will probably cause it not to print. |