round

Round an integer to a certain decimal place according to rounding mode

  1. long round(long x, int dec_place)
    long
    round
    (
    long x
    ,)
    out (result) { assert ((result % pow10(dec_place)) == 0); }
  2. real round(real x, roundingMode m)

Examples

assert (round!(roundingMode.DOWN)     (1009, 1) == 1000);
assert (round!(roundingMode.UP)       (1001, 1) == 1010);
assert (round!(roundingMode.HALF_UP)  (1005, 1) == 1010);
assert (round!(roundingMode.HALF_DOWN)(1005, 1) == 1000);

Meta