Friday, February 17, 2012

Order of precedence for calculations in Scratch

Can you spot the difference? 
the answer is 70 in this case



The answer is 0 in this case




In Mathematics the answers would  have been the same, but when you build expressions in Scratch, each building block is like a set of brackets:
((7/10)*100)  = 0.7 * 100  = 70
(7/(10*100))  = 7/1000 = 0.007 which displays 0

Keep this in mind to avoid logical errors

No comments:

Post a Comment