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
- 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,
round,
shortValue,
subtract,
toBigDecimal,
toBigInteger,
toString |
Product
protected Product(RealNumber a,
RealNumber b)
throws 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:
- IllegalArgumentException - if
a == null || b == null.
createInstance
public static Product createInstance(RealNumber a,
RealNumber b)
throws 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:
- IllegalArgumentException - if
a == null || b == null.
determineSign
protected static int determineSign(RealNumber a,
RealNumber b)
throws 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:
- IllegalArgumentException - if
a == null || b == null.
toBigDecimal
public BigDecimal toBigDecimal(int precision,
int roundingMode)
throws IllegalArgumentException
- Converts the value of this number to a
BigDecimal with the
specified precision and rounding mode.
- Overrides:
- 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:
- 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/.