Class nl.coffee.math.BasicRationalNumber
java.lang.Object
|
+--java.lang.Number
|
+--nl.coffee.math.AbstractRealNumber
|
+--nl.coffee.math.AbstractRationalNumber
|
+--nl.coffee.math.BasicRationalNumber
- public class BasicRationalNumber
- extends AbstractRationalNumber
Basic implementation of a rational number, i.e. a fraction.
This implementation simply encapsulates a numerator and
a denominator field. Both are IntegerNumber
objects.
- Since:
- JUMP_1.0
- Version:
- 1.1 199809.24
- Author:
- Ernst de Haan
- See Also:
- Serialized Form
Methods inherited from class nl.coffee.math.AbstractRationalNumber |
add, add, compareTo, divide, divide, doubleValue, getSign, invert, multiply, multiply, negate, pow, pow, retryCompare, retryCompare, subtract, subtract, toBigDecimal, toBigDecimal, toString, trunc |
Methods inherited from class nl.coffee.math.AbstractRealNumber |
abs, add, byteValue, compareTo, divide, doubleValue, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, hashCode, intValue, invert, longValue, multiply, negate, pow, retryCompare, shortValue, subtract, toBigDecimal, toBigInteger |
Methods inherited from class java.lang.Number |
byteValue, doubleValue, floatValue, intValue, longValue, shortValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
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.
numerator
public final IntegerNumber numerator
- The numerator of this fraction.
denominator
public final IntegerNumber denominator
- The denominator of this fraction.
BasicRationalNumber
protected BasicRationalNumber(IntegerNumber numerator,
IntegerNumber denominator)
throws java.lang.IllegalArgumentException,
java.lang.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:
- java.lang.IllegalArgumentException - if one of the following applies:
- numerator ==
null
- denominator ==
null
- java.lang.ArithmeticException - if the value of denominator is zero.
createInstance
public static BasicRationalNumber createInstance(IntegerNumber numerator,
IntegerNumber denominator)
throws java.lang.IllegalArgumentException,
java.lang.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:
- java.lang.IllegalArgumentException - if one of the following applies:
- numerator ==
null
- denominator ==
null
- java.lang.ArithmeticException - if the value of
denominator
is zero.
getNumerator
public IntegerNumber getNumerator()
getDenominator
public IntegerNumber getDenominator()