Class RoundingModes

java.lang.Object
org.zkoss.math.RoundingModes

public class RoundingModes extends Object
Utilities to handle the rounding mode.
Author:
tomyeh
  • Method Details

    • toString

      public static final String toString(int roundingMode)
      Returns the name of the rounding mode. Possible values include
      CEILING
      Rounding mode to round towards positive infinity.
      DOWN
      Rounding mode to round towards zero.
      FLOOR
      Rounding mode to round towards negative infinity.
      HALF_DOWN
      Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
      HALF_EVEN
      Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
      HALF_UP
      Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
      UNNECESSARY
      Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
      UP
      Rounding mode to round away from zero.
    • valueOf

      public static final int valueOf(String name)
      Returns the rounding mode of the specified name.
      Parameters:
      name - the rounding mode's name. Allowed values include:
      CEILING
      Rounding mode to round towards positive infinity.
      DOWN
      Rounding mode to round towards zero.
      FLOOR
      Rounding mode to round towards negative infinity.
      HALF_DOWN
      Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
      HALF_EVEN
      Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
      HALF_UP
      Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
      UNNECESSARY
      Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
      UP
      Rounding mode to round away from zero.