Enum TRoundingMode

java.lang.Object
java.lang.Enum<TRoundingMode>
org.teavm.classlib.java.math.TRoundingMode
All Implemented Interfaces:
Serializable, Comparable<TRoundingMode>, java.lang.constant.Constable

public enum TRoundingMode extends Enum<TRoundingMode>
Specifies the rounding behavior for operations whose results cannot be represented exactly.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Rounding mode to round towards positive infinity.
    Rounding mode where the values are rounded towards zero.
    Rounding mode to round towards negative infinity.
    Rounding mode where values are rounded towards the nearest neighbor.
    Rounding mode where values are rounded towards the nearest neighbor.
    Rounding mode where values are rounded towards the nearest neighbor.
    Rounding mode where the rounding operations throws an ArithmeticException for the case that rounding is necessary, i.e.
    Rounding mode where positive values are rounded towards positive infinity and negative values towards negative infinity.
  • Method Summary

    Modifier and Type
    Method
    Description
    valueOf​(int mode)
    Converts rounding mode constants from class BigDecimal into RoundingMode values.
    valueOf​(String name)
    Returns the enum constant of this type with the specified name.
    static TRoundingMode[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • UP

      public static final TRoundingMode UP
      Rounding mode where positive values are rounded towards positive infinity and negative values towards negative infinity.
      Rule: x.round().abs() >= x.abs()
    • DOWN

      public static final TRoundingMode DOWN
      Rounding mode where the values are rounded towards zero.
      Rule: x.round().abs() <= x.abs()
    • CEILING

      public static final TRoundingMode CEILING
      Rounding mode to round towards positive infinity. For positive values this rounding mode behaves as UP, for negative values as DOWN.
      Rule: x.round() >= x
    • FLOOR

      public static final TRoundingMode FLOOR
      Rounding mode to round towards negative infinity. For positive values this rounding mode behaves as DOWN, for negative values as UP.
      Rule: x.round() <= x
    • HALF_UP

      public static final TRoundingMode HALF_UP
      Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding up.
    • HALF_DOWN

      public static final TRoundingMode HALF_DOWN
      Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding down.
    • HALF_EVEN

      public static final TRoundingMode HALF_EVEN
      Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding to the even neighbor.
    • UNNECESSARY

      public static final TRoundingMode UNNECESSARY
      Rounding mode where the rounding operations throws an ArithmeticException for the case that rounding is necessary, i.e. for the case that the value cannot be represented exactly.
  • Method Details

    • values

      public static TRoundingMode[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static TRoundingMode valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • valueOf

      public static TRoundingMode valueOf(int mode)
      Converts rounding mode constants from class BigDecimal into RoundingMode values.
      Parameters:
      mode - rounding mode constant as defined in class BigDecimal
      Returns:
      corresponding rounding mode object