Class MathUtils

java.lang.Object
ch.tocco.nice2.toolbox.api.math.MathUtils

public class MathUtils extends Object
Static class providing utility methods for maths tasks
  • Method Details

    • round

      public static BigDecimal round(BigDecimal value, BigDecimal rounding)
      round a decimal value to a multiple of rounding.
      • Examples:
        • value: 4.3, rounding: 0.25, result: 4.25
        • value: 4.3, rounding: 0.5, result: 4.5
      Parameters:
      value - a value to round
      rounding - a decimal number to round to. Possible values are all elements of {1 / n | n ∈ {1, 2, 3, ...}} ∪ {1, 2, 3, ...}
      Returns:
      the rounded value