Thursday, February 24, 2022

Fun With Rounding Errors

I love xkcd cartoons. I came across this one thing morning that shows the benefits(?) or rounding up.

My immediate idea was “what a great programming project!”  One of the first “hello world” type of exercises I often assign is simple conversations. Fahrenheit to centigrade, miles to kilometers, etc. This is a step beyond that but with a difference. The difference is rounding up and its effect on accuracy.

This is a good program to use to introduce rounding in general but to also talk about how rounding errors can have a large impact when they occur over and over again.

This example uses velocity but I can imaging there are interesting results with weights, simple distances, and almost anything else that normally requires better than integer accuracy. Currency anyone? I’m thinking about trying that one because it involves money.

It might be interesting and educational to try the difference between rounding normally, always rounding up, and always rounding down.

What do you think? Anyone doing something like this? Would it be useful?

No comments: