Package com.google.common.math
Class ToDoubleRounder<X extends java.lang.Number & java.lang.Comparable<X>>
- java.lang.Object
-
- com.google.common.math.ToDoubleRounder<X>
-
- Direct Known Subclasses:
BigDecimalMath.BigDecimalToDoubleRounder
,BigIntegerMath.BigIntegerToDoubleRounder
abstract class ToDoubleRounder<X extends java.lang.Number & java.lang.Comparable<X>> extends java.lang.Object
Helper type to implement roundingX
to a representabledouble
value according to aRoundingMode
.
-
-
Constructor Summary
Constructors Constructor Description ToDoubleRounder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods 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) double
roundToDouble(X x, java.math.RoundingMode mode)
Roundsx
to adouble
.(package private) 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.(package private) abstract int
sign(X x)
Returns the sign of x: either -1, 0, or 1.(package private) abstract X
toX(double d, java.math.RoundingMode mode)
Returns d's value as an X, rounded with the specified mode.
-
-
-
Method Detail
-
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, java.math.RoundingMode mode)
Returns d's value as an X, rounded with the specified mode.
-
roundToDouble
final double roundToDouble(X x, java.math.RoundingMode mode)
Roundsx
to adouble
.
-
-