round method

Dimension round (
  1. Node n,
  2. [Node f]
)

Applies rounding.

Parameters: number: A floating point number. decimalPlaces: Optional: The number of decimal places to round to. Defaults to 0. Returns: number Example: round(1.67) Output: 2 Example: round(1.67, 1) Output: 1.7

Implementation

Dimension round(Node n, [Node f]) {
  final num fraction = (f == null) ? 0 : f.value;

  return MathHelper._math((num d) {
    final exp = math.pow(10, fraction).toDouble();
    return (d * exp).roundToDouble() / exp;
  }, null, n);

//    mathFunctions.round = function (n, f) {
//        var fraction = typeof(f) === "undefined" ? 0 : f.value;
//        return _math(function(num) { return num.toFixed(fraction); }, null, n);
//    };
}