org.znerd.math
Class BasicRationalNumber
java.lang.Object
|
+--java.lang.Number
|
+--org.znerd.math.RealNumber
|
+--org.znerd.math.RationalNumber
|
+--org.znerd.math.BasicRationalNumber
- public class BasicRationalNumber
- extends RationalNumber
Basic implementation of a rational number.
This implementation simply encapsulates a numerator and
a denominator field. Both are IntegerNumber
objects.
- Version:
- $Revision: 1.8 $ $Date: 2002/08/16 22:07:32 $
- Author:
- Ernst de Haan (znerd@FreeBSD.org)
- See Also:
- Serialized Form
Methods inherited from class org.znerd.math.RationalNumber |
add,
add,
compareTo,
compareToImpl,
compareToImpl,
compareToImpl2,
divide,
divide,
doubleValue,
getDenominator,
getNumerator,
invert,
multiply,
multiply,
negate,
pow,
pow,
subtract,
subtract,
toBigDecimal,
toBigDecimal,
trunc |
Methods inherited from class org.znerd.math.RealNumber |
abs,
byteValue,
compareTo,
compareTo,
equals,
fitsByte,
fitsDouble,
fitsFloat,
fitsInt,
fitsLong,
fitsShort,
floatValue,
getSign,
intValue,
longValue,
round,
shortValue,
toBigInteger,
toString |
ONE_HALF
public static final BasicRationalNumber ONE_HALF
- Cached instance that represents the number one half, 1/2.
MINUS_ONE_HALF
public static final BasicRationalNumber MINUS_ONE_HALF
- Cached instance that represents the number minus one half, -1/2.
BasicRationalNumber
protected BasicRationalNumber(IntegerNumber numerator,
IntegerNumber denominator)
throws IllegalArgumentException,
ArithmeticException
- Constructs a new
BasicRationalNumber
from a numerator and
a denominator.
- Parameters:
numerator
- the numerator for the fraction.denominator
- the denominator for the fraction.- Throws:
- IllegalArgumentException - if one of the following applies:
- numerator ==
null
- denominator ==
null
- ArithmeticException - if the value of denominator is zero.
createInstance
public static BasicRationalNumber createInstance(IntegerNumber numerator,
IntegerNumber denominator)
throws IllegalArgumentException,
ArithmeticException
- Returns an instance of a
BasicRationalNumber
with the
given numerator and denominator.
- Parameters:
numerator
- the numerator for the fraction.denominator
- the denominator for the fraction.- Returns:
- the (possibly newly constructed) instance.
- Throws:
- IllegalArgumentException - if one of the following applies:
- numerator ==
null
- denominator ==
null
- ArithmeticException - if the value of
denominator
is zero.
See http://jump-math.sourceforge.net/.