MakeCode Arcade Precision Activities
The following MakeCode Arcade programs can help you see approximation and overflow errors in action.
Floating Point and Overflow
Click on Edit Code to open the program.
When you run this program, it is dividing 17 by 5 and displaying the result.
- Replace the 17 with 3.4. What is the calculation now?
- Perform the same calculation on a calculator. What is the answer?
- Why do you think they are different?
- Replace 3.4 with it with 0.00000000001. What is the calculation now?
- Now, change the calculation to a multiplication rather than division
Once you change to multiplication change the number to calculate a large number. Keep changing the numbers until it reaches overflow.
- Now try using the myint and myfloat variables in your calculation. Hint - look in the Variables Toolbox drawer
Is the result an integer or a floating point number?
- From the Info Toolbox drawer, pull out a Set Score block and place after the mySprite Say block. From the Text Toolbox drawer, pull out a Parse to Number block and place in the Set Score block. In the Parse to Number block type "7.5e2".
What happpens?
Approximation
Click on Edit Code to open the program.
What is the value of x?
What is the value of y?
According to the algorithm, is the program correct, when it displays "False"?
Why or why not? What is going on? Hint: move the mySprite say block
out of the source code and replace it with the other disabled mySprite say block on the workspace
Use the drop-down menu to change the variables