k, your turn now indeed
Let's continue with list questions...
MSX-BASIC knows the rules in what order calculations should be done. How about you?
Order these 10 mathematical operations to order they are executed on MSX-BASIC:
1. "MOD"
2. "XOR"
3. "\"
4. "AND" & "IMP"
5. "=" & "<" & ">"
6. "OR"
7. "*" & "/"
8. "+" & "-" (as calculation not as sign)
9. "^"
10. "NOT" & "EQV"
No one?
I don't expect you to get everything correct at one time, but you must know something...
ie. You know that 2+3*4=14 and not 20 because "*" is calculated before "+"
You propably also know that when you see:
IF A=B AND C=D THEN ...
you know that it is not equal to:
IF A=(B AND C)=D THEN ...
Hint: by doing similar tests you can solve this puzzle.
Do a sophisticated quess and I'll give more hints...
I will start investigation to make things moving.
10 mod 4 / 2 = 0
(10 mod 4) / 2 = 1
so MOD is done after /
10 mod 4 + 1 = 3
so MOD is done before +
So far so good... MOD is also good operation to start as it is in the middle of the list.
100 \ 3 / 2 = 100
(100 \ 3) / 2 = 16.5
This means / works before \
100 MOD 15 \ 10 = 0
(100 MOD 15) \ 10 = 1
Result: \ done before MOD
So far the order is:
(a) 7. "*" & "/"
(b) 3. "\"
(c) 1. "MOD"
(d) 8. "+" & "-" (as calculation not as sign)
6 operations (mostly boolean) to be added.
Very good!
Now if you think for example circle and
then you should know where to put "^" ;)
- Obviously degree symbol "^" has the highest arithmetic precedence.
- Booleans:
1 or 0 and 0 = 1
(1 or 0) and 0 = 0
so AND calculated before OR
1 xor 1 and 0 = 1
(1 xor 1) and 0 = 0
This time AND wins again
1 xor 0 or 1 = 0
(1 xor 0) or 1 = 1
XOR lost again.
"NOT" if I remember correctly has the highest logical precedence,
Obviously "=" (comparison) is done when everything is done, and all logic is done after arithmetic operations.
This gives us:
(a) 9. "^"
(b) 7. "*" & "/"
(c) 3. "\"
(d) 1. "MOD"
(e) 8. "+" & "-" (as calculation not as sign)
(f) 10. "NOT" & "EQV"
(g) 4. "AND" & "IMP"
(h) 6. "OR"
(i) 2. "XOR"
(j) 5. "=" & "<" & ">"
I hope this is correct, and I have to say I forgot what IMP and EQV do...
Very close... How ever "obviously" you are wrong and not done.
How about this :
9. "^"
7. "*" & "/"
3. "\"
1. "MOD"
8. "+" & "-" (as calculation not as sign)
10. "NOT" & "EQV"
5. "=" & "<" & ">"
4. "AND" & "IMP"
6. "OR"
2. "XOR"
