Class Product
- All Implemented Interfaces:
Serializable, Comparable, RoundingModes
A product of two real numbers.
- Version:
- $Revision: 1.5 $ $Date: 2002/08/16 21:35:50 $
- Author:
- Ernst de Haan (znerd@FreeBSD.org)
- See Also:
-
Field Summary
Fields inherited from class RealNumber
MAXIMUM_RADIXFields inherited from interface RoundingModes
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProduct(RealNumber a, RealNumber b) Constructs aProductbased on the 2 specified operands. -
Method Summary
Modifier and TypeMethodDescriptionstatic ProductReturns aProductwith the specified operands.protected static intComputes the sign of a product with the specified operands.toBigDecimal(int precision, int roundingMode) Converts the value of this number to aBigDecimalwith the specified precision and rounding mode.trunc()Rounds to an integer number towards 0.Methods inherited from class AbstractCompositeNumber
getElement, getElementCount, getElementsMethods inherited from class RealNumber
abs, add, byteValue, compareTo, compareTo, compareToImpl, divide, doubleValue, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, getSign, intValue, invert, longValue, multiply, negate, pow, powImpl, round, shortValue, subtract, toBigDecimal, toBigInteger, toString
-
Constructor Details
-
Product
Constructs aProductbased on the 2 specified operands.- Parameters:
a- the first operand for the product, notnull.b- the second operand for the product, notnull.- Throws:
IllegalArgumentException- ifa == null || b == null.
-
-
Method Details
-
createInstance
Returns aProductwith the specified operands.- Parameters:
a- the first operand, notnull.b- the second operand, notnull.- Returns:
- the
Productinstance, possibly newly constructed, nevernull. - Throws:
IllegalArgumentException- ifa == null || b == null.
-
determineSign
Computes the sign of a product with the specified operands.- Parameters:
a- the first operand, notnull.b- the second operand, notnull.- Returns:
- the sign for the product of
aandb. - Throws:
IllegalArgumentException- ifa == null || b == null.
-
toBigDecimal
Converts the value of this number to aBigDecimalwith the specified precision and rounding mode.- Specified by:
toBigDecimalin classRealNumber- Parameters:
precision- the number of digits behind the decimal point, >= 0.roundingMode- the rounding mode to use, one of the modes defined in classBigDecimal.- Returns:
- a
BigDecimalwith the rounded value of this number, nevernull. - Throws:
IllegalArgumentException- ifprecision < 0or if the rounding mode is not one of the valid rounding modes defined inBigDecimal.
-
trunc
Rounds to an integer number towards 0.- Overrides:
truncin classRealNumber- Returns:
- this number truncated to an integer, not
null.
-