roundedTo

roundedTo(decimalPlaces: Integer): Decimal;

The roundedTo method of the Decimal primitive type returns the receiver rounded to the number of decimal places specified in the decimalPlaces parameter.

The following code fragment shows the use of the roundedTo method.

write (3.64).Decimal.roundedTo(1);   // outputs 3.6 [0,1,2,3,4 are rounded down]
write (3.65).Decimal.roundedTo(1);   // outputs 3.7 [5,6,7,8,9 are rounded up]

write (-3.64).Decimal.roundedTo(1);  // outputs -3.6 [0,1,2,3,4 are rounded up]
write (-3.65).Decimal.roundedTo(1);  // outputs -3.7 [5,6,7,8,9 are rounded down]