Discussion

Bug: NOT affects the sign of it's neighbor

1

SP4CEBAR 2023-01-05 20:58 (Edited)

PRINT ( NOT(-1) ) +2
PRINT   NOT(-1)   +2

'The first gives "2", the second gives "-2"
'In other words NOT is messing with it's neighbors

'It's probably the same reason why "PRINT -NOT(-1)" causes a syntax error


nathanielbabiak 2023-01-06 00:18 (Edited)

This is a feature, not a bug...

The NOT operator is a Boolean operator, it isn't a function. This is the order of operations that LowRes NX uses (from left to right):

'ORDER OF OPERATIONS: () ^ - */\ MOD +- <>=<=> NOT AND ORXOR =

In your first line, the -1 is not'd, resulting in 0, then 2 is added.

In your second line, the parenthesis around the -1 take place first, creating the value "-1", then the addition occurs, then the NOT occurs last.

The syntax error you get with PRINT -NOT(-1) is related to trying to take a negative first (due to order of operations), then taking NOT(-1). The negative operator doesn't have anything to work on, which is why it yields a syntax error.


GAMELEGEND 2023-01-06 00:58

How are you so good at explaining things?


nathanielbabiak 2023-01-06 01:55 (Edited)

Gamelegend, it just so happens that my professional skillset is very transferrable to explaining how LowRes NX works. This is me.


was8bit 2023-01-06 15:42

My experience is that you MUST carefully use parenthesis if you have lots of math things going on ...


In a worst case scenario, if you still can't get the results you want, break the math down into smaller parts...

.... I can do math ok, but my mind has trouble doing multiple things at once... so the more math stacked or layered up into one group, the harder it is for me to think thru it... so I tend to break things down into smaller, more manageable portions...

Also, if you are trying to debug your code, smaller parts make it easier to use TRACE for specific parts of your math so you can analyze where you made your mistake... ;)


SP4CEBAR 2023-01-06 22:01 (Edited)

@nthanielbabiak
Thanks! I always treated NOT as a function (NOT()), I didn't know you could write "NOT -1"


Also thanks for the order of operations list, I was trying to make one a little while ago, but I found it too much work


Timo 2023-01-07 14:52

You can find the order of operations in the manual.


SP4CEBAR 2023-01-07 14:58 (Edited)

Oh, thanks I probably was never looking for it and I forgot it was even there


Log in to reply.