org.znerd.math
public class Product extends AbstractCompositeNumber
MAXIMUM_RADIX
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP
Modifier | Constructor and Description |
---|---|
protected |
Product(RealNumber a,
RealNumber b)
Constructs a
Product based on the 2 specified operands. |
Modifier and Type | Method and Description |
---|---|
static Product |
createInstance(RealNumber a,
RealNumber b)
Returns a
Product with the specified operands. |
protected static int |
determineSign(RealNumber a,
RealNumber b)
Computes the sign of a product with the specified operands.
|
java.math.BigDecimal |
toBigDecimal(int precision,
int roundingMode)
Converts the value of this number to a
BigDecimal with the
specified precision and rounding mode. |
IntegerNumber |
trunc()
Rounds to an integer number towards 0.
|
getElement, getElementCount, getElements
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
protected Product(RealNumber a, RealNumber b) throws java.lang.IllegalArgumentException
Product
based on the 2 specified operands.a
- the first operand for the product, not null
.b
- the second operand for the product, not null
.java.lang.IllegalArgumentException
- if a == null || b == null
.public static Product createInstance(RealNumber a, RealNumber b) throws java.lang.IllegalArgumentException
Product
with the specified operands.a
- the first operand, not null
.b
- the second operand, not null
.Product
instance, possibly newly constructed, never
null
.java.lang.IllegalArgumentException
- if a == null || b == null
.protected static int determineSign(RealNumber a, RealNumber b) throws java.lang.IllegalArgumentException
a
- the first operand, not null
.b
- the second operand, not null
.a
and b
.java.lang.IllegalArgumentException
- if a == null || b == null
.public java.math.BigDecimal toBigDecimal(int precision, int roundingMode) throws java.lang.IllegalArgumentException
BigDecimal
with the
specified precision and rounding mode.toBigDecimal
in class RealNumber
precision
- the number of digits behind the decimal point, >= 0.roundingMode
- the rounding mode to use, one of the modes defined in class
BigDecimal
.BigDecimal
with the rounded value of this number,
never null
.java.lang.IllegalArgumentException
- if precision < 0
or if the rounding mode is not one
of the valid rounding modes defined in BigDecimal
.public IntegerNumber trunc()
trunc
in class RealNumber
null
.