ABSOLUTE BEGINNER
Your first rounding
Turn a decimal into a nearby whole number, then compare rounding down and rounding up in five tiny Squeak steps.
STEP 1
Round a number
Open a Workspace from Squeak's World menu. Type this line, select all of it, then choose Print it from the text menu.
3.7 rounded
You should see 4. Remove the selected answer before trying another line.
STEP 2
Try a smaller decimal
rounded chooses a nearest whole number. Here the nearest whole number is 3.
3.2 rounded
You should see 3.
STEP 3
Go down
floor chooses the whole number at or below your number.
3.7 floor
You should see 3, even though 3.7 is closer to 4.
STEP 4
Go up
ceiling chooses the whole number at or above your number.
3.2 ceiling
You should see 4.
STEP 5
Try a negative number
Down means further left on the number line. Write the negative number inside parentheses.
(-3.2) floor
You should see -4. Try (-3.2) ceiling too: it gives -3.
YOU DID IT
A small step. A real result.
rounded chooses a nearby whole number. floor goes down; ceiling goes up. Try these messages on both positive and negative numbers.
Optional code download: open it as text and copy one example into Workspace.