In this lecture we discuss various ways to round numbers.
Your challenge is to take the number 6.283 and:
- Find the Floor of the number
- Find the Ceiling of the number
- Round the number to both 1 & 2 decimal places.
Pop your answer below and remember to use the spoiler tags.
I’d also like to mention that the code examples in the video are in pseudo-code only. So whilst many languages will have a similar syntax to how I’ve written them, it’s always best to check the documentation for your language of choice - otherwise you may get caught out by some unexpected behaviour.
For example, the System.Math library in C# doesn’t use traditional midpoint rounding and instead uses something commonly known as banker’s rounding, so you have to explicitly change this if you want things to work how you expect.