round method

Decimal round({
  1. int scale = 0,
})

Returns the Decimal value closest to this number.

Rounds away from zero when there is no closest integer: (3.5).round() == 4 and (-3.5).round() == -4.

An optional scale value can be provided as parameter to indicate the digit used as reference for the operation.

var x = Decimal.parse('123.4567');
x.round(); // 123
x.round(scale: 1); // 123.5
x.round(scale: 2); // 123.46
x.round(scale: -1); // 120

Implementation

Decimal round({int scale = 0}) => _scaleAndApply(scale, (e) => e.round());