org.znerd.math
Class Product
java.lang.Object
java.lang.Number
org.znerd.math.RealNumber
org.znerd.math.CompositeNumber
org.znerd.math.AbstractCompositeNumber
org.znerd.math.Product
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable, RoundingModes
public class Product
- extends AbstractCompositeNumber
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:
- Serialized Form
Methods inherited from class org.znerd.math.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 |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Product
protected Product(RealNumber a,
RealNumber b)
throws java.lang.IllegalArgumentException
- Constructs a
Product
based on the 2 specified operands.
- Parameters:
a
- the first operand for the product, not null
.b
- the second operand for the product, not null
.
- Throws:
java.lang.IllegalArgumentException
- if a == null || b == null
.
createInstance
public static Product createInstance(RealNumber a,
RealNumber b)
throws java.lang.IllegalArgumentException
- Returns a
Product
with the specified operands.
- Parameters:
a
- the first operand, not null
.b
- the second operand, not null
.
- Returns:
- the
Product
instance, possibly newly constructed, never
null
.
- Throws:
java.lang.IllegalArgumentException
- if a == null || b == null
.
determineSign
protected static int determineSign(RealNumber a,
RealNumber b)
throws java.lang.IllegalArgumentException
- Computes the sign of a product with the specified operands.
- Parameters:
a
- the first operand, not null
.b
- the second operand, not null
.
- Returns:
- the sign for the product of
a
and b
.
- Throws:
java.lang.IllegalArgumentException
- if a == null || b == null
.
toBigDecimal
public java.math.BigDecimal toBigDecimal(int precision,
int roundingMode)
throws java.lang.IllegalArgumentException
- Converts the value of this number to a
BigDecimal
with the
specified precision and rounding mode.
- Specified by:
toBigDecimal
in class RealNumber
- Parameters:
precision
- the number of digits behind the decimal point, >= 0.roundingMode
- the rounding mode to use, one of the modes defined in class
BigDecimal
.
- Returns:
- a
BigDecimal
with the rounded value of this number,
never null
.
- Throws:
java.lang.IllegalArgumentException
- if precision < 0
or if the rounding mode is not one
of the valid rounding modes defined in BigDecimal
.
trunc
public IntegerNumber trunc()
- Rounds to an integer number towards 0.
- Overrides:
trunc
in class RealNumber
- Returns:
- this number truncated to an integer, not
null
.
See http://jump-math.sourceforge.net/.