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.1 $ $Date: 2002/06/05 22:23:15 $
- 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,
shortValue,
subtract,
toBigDecimal,
toBigInteger,
toString |
Product
protected Product(RealNumber a,
RealNumber b)
throws IllegalArgumentException
- Constructs a
Product
based on the 2 specified operands.
- Parameters:
operand1
- the first operand for the product.operand2
- the second operand for the product.- Throws:
- IllegalArgumentException - if either argument
is
null
.
createInstance
public static Product createInstance(RealNumber a,
RealNumber b)
throws IllegalArgumentException
- Returns a
Product
with the specified operands.
- Parameters:
a
- the first operand.b
- the second operand.- Returns:
- the
Product
instance, possibly newly constructed. - Throws:
- IllegalArgumentException - if either argument is
null
.
determineSign
protected static int determineSign(RealNumber a,
RealNumber b)
- Computes the sign of a product with the specified operands.
- Parameters:
a
- the first operand, not null
.b
- the second operand, not null
.
retryCompare
public int retryCompare(RealNumber n)
throws IllegalArgumentException,
CanNotCompareException
- Returns -1, 0 or 1 as this number is less than, equal to, or greater
than n, where n is a real number.
- Parameters:
n
- the number to compare to.- Returns:
- -1 if this<n, 0 if this==n, 1 if
this>n.
- Throws:
- IllegalArgumentException - if the argument is
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.roundingMode
- the rounding mode to use, one of the modes defined
in class BigDecimal
.- Returns:
- a
BigDecimal
with the rounded value of this. - Throws:
- IllegalArgumentException - if precision<0 or
the rounding mode is not one of the valid rounding modes defined in
class
BigDecimal
.
trunc
public IntegerNumber trunc()
- Rounds to an integer number towards 0.
- Overrides:
- trunc in class RealNumber
- Returns:
- this number truncated to an integer.
asString
public String asString()
- Returns a textual representation of this object.
- Returns:
- a
String
representation of this object.
See http://jump-math.sourceforge.net/.