Class ToDoubleRounder<X extends Number & Comparable<X>>

java.lang.Object
com.google.common.math.ToDoubleRounder<X>
Direct Known Subclasses:
BigDecimalMath.BigDecimalToDoubleRounder, BigIntegerMath.BigIntegerToDoubleRounder

abstract class ToDoubleRounder<X extends Number & Comparable<X>> extends Object
Helper type to implement rounding X to a representable double value according to a RoundingMode.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) abstract X
    minus(X a, X b)
    Returns a - b, guaranteed that both arguments are nonnegative.
    (package private) final double
    Rounds x to a double.
    (package private) abstract double
    Returns x rounded to either the greatest double less than or equal to the precise value of x, or the least double greater than or equal to the precise value of x.
    (package private) abstract int
    sign(X x)
    Returns the sign of x: either -1, 0, or 1.
    (package private) abstract X
    toX(double d, RoundingMode mode)
    Returns d's value as an X, rounded with the specified mode.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ToDoubleRounder

      ToDoubleRounder()
  • Method Details

    • roundToDoubleArbitrarily

      abstract double roundToDoubleArbitrarily(X x)
      Returns x rounded to either the greatest double less than or equal to the precise value of x, or the least double greater than or equal to the precise value of x.
    • sign

      abstract int sign(X x)
      Returns the sign of x: either -1, 0, or 1.
    • toX

      abstract X toX(double d, RoundingMode mode)
      Returns d's value as an X, rounded with the specified mode.
    • minus

      abstract X minus(X a, X b)
      Returns a - b, guaranteed that both arguments are nonnegative.
    • roundToDouble

      final double roundToDouble(X x, RoundingMode mode)
      Rounds x to a double.