Game Math - Rounding Challenge

Challenge Question Answers:

6.283
Floor: 6.0
Ceiling: 7.0

1 Decimal Place:
Floor: 6.2
Ceiling: 6.3

2 Decimal Places:
Floor: 6.28
Ceiling: 6.29

1 Like

I think it’s important to note that floor and ceiling only return an integer. So you wouldn’t have a floor or ceiling with a decimal

Excellent point, HenRMJ. The challenge was to calculate it to 1 and 2 decimal places, though. Not sure if that means they should all just be “zero”. :smiley:

If we were seeking a decimal value we could just multiple it by 10 or 100 and then divide by the same.

Example:

a = Math.Floor(6.283 * 10) / 10
a = Math.Ceil(6.283 * 10) / 10

a = Math.Floor(6.283 * 100) / 100
a = Math.Ceil(6.283 * 100) / 100

Privacy & Terms