Jack Burns
New Member
Being as maths is performed strictly from left to right, can anyone see why these 2 subroutines behave differently (on chip and simulator)?
I would expect the
Test1 will return with b3 = 1
Test2 will return with b4 = 0
I know I can code it differently, however I'm just wondering why it's not working as expected.
I would expect the
Or b1 > $29
in Test1 to cause the subroutine to return with b3 = 0, but that's not happening...Test1 will return with b3 = 1
Test2 will return with b4 = 0
I know I can code it differently, however I'm just wondering why it's not working as expected.
Rich (BB code):
b1 = $30
b2 = $00
Gosub Test1 ' Doesn't work as expected.
Gosub Test2 ' Works as expected.
End
Test1:
' Expected evaluation ((b1 = $29) And (b2 > $00)) Or (b1 > $29)
b3 = 0
If b1 = $29 And b2 > $00 Or b1 > $29 Then : Return : End If
b3 = 1
Return
Test2:
' Breaking Test 1 down, it works as expected.
b4 = 0
If b1 = $29 And b2 > $00 Then : Return : End If
If b1 > $29 Then : Return : End If
b4 = 1
Return