The Amazing Neverending MSX quiz - Part 3

Page 16/52
9 | 10 | 11 | 12 | 13 | 14 | 15 | | 17 | 18 | 19 | 20 | 21

By hap

Paragon (2042)

hap's picture

04-09-2010, 17:33

k, your turn now indeed Smile

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

04-09-2010, 18:00

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"

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

05-09-2010, 11:56

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...

By cax

Prophet (3740)

cax's picture

06-09-2010, 07:10

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 +

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

06-09-2010, 07:21

So far so good... MOD is also good operation to start as it is in the middle of the list.

By cax

Prophet (3740)

cax's picture

06-09-2010, 10:47

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.

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

06-09-2010, 15:21

Very good!

Now if you think for example circle and upload.wikimedia.org/math/2/9/3/2939d1d147127d19da4436b04cbcab72.png then you should know where to put "^" ;)

By cax

Prophet (3740)

cax's picture

06-09-2010, 22:14

- 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...

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

07-09-2010, 04:45

Very close... How ever "obviously" you are wrong and not done.

By cax

Prophet (3740)

cax's picture

07-09-2010, 09:34

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"

Page 16/52
9 | 10 | 11 | 12 | 13 | 14 | 15 | | 17 | 18 | 19 | 20 | 21