NumericUtil

NumericUtil class provides utility methods for numerical operations.

Methods

round(value: Double, places: Integer): Double

  • Rounds a number to the specified number of decimal places using the default rounding mode (HALF_UP).

var value = 3.14159;
var roundedValue = NumericUtil.round(value, 2);
return roundedValue; // Output: 3.14

roundUp(value: Double, places: Integer): Double

  • Rounds a number up to the specified number of decimal places, always rounding up to the nearest value.

var value = 3.14159;
var roundedValue = NumericUtil.roundUp(value, 2);
return roundedValue; // Output: 3.14

roundDown(value: Double, places: Integer): Double

  • Rounds a number down to the specified number of decimal places, always rounding down to the nearest value.

var value = 3.14159;
var roundedValue = NumericUtil.roundDown(value, 2);
return roundedValue; // Output: 3.14