Class nl.coffee.math.AbstractRationalNumber
java.lang.Object
|
+--java.lang.Number
|
+--nl.coffee.math.AbstractRealNumber
|
+--nl.coffee.math.AbstractRationalNumber
- Subclasses:
- AbstractIntegerNumber, BasicRationalNumber
- public abstract class AbstractRationalNumber
- extends AbstractRealNumber
- implements RationalNumber
Abstract base class for RationalNumber
implementations.
Concrete subclasses should at least provide an implementations for the
following methods:
getNumerator()
--
Returns the numerator of this fraction
getDenominator()
--
Returns the denominator of this fraction
IntegerNumber
implementations based on this class must
override the following methods:
getSign()
--
The implementation in this class returns
the sign of the numerator, which is this
in an
IntegerNumber
implementation
negate()
--
The implementation in this class returns a
fraction with a negated numerator, which is this
in an
IntegerNumber
implementation
toString()
--
The implementation in this class
returns a string representation of the numerator and the string
representation of the denominator; in an IntegerNumber
implementation the numerator is this
- Since:
- JUMP_1.0
- Version:
- 1.2 199809.24
- Author:
- Ernst de Haan
- See Also:
- Serialized Form
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 |
AbstractRationalNumber
protected AbstractRationalNumber()
- Constructs a new
AbstractRationalNumber
.
compareTo
public int compareTo(RationalNumber n)
throws java.lang.IllegalArgumentException
- Description copied from interface:
- Specified by:
- compareTo in interface RationalNumber
getSign
public int getSign()
retryCompare
public int retryCompare(RealNumber n)
throws java.lang.IllegalArgumentException,
CanNotCompareException
- Overrides:
- retryCompare in class AbstractRealNumber
retryCompare
public int retryCompare(RationalNumber n)
throws java.lang.IllegalArgumentException
negate
public RealNumber negate()
- Overrides:
- negate in class AbstractRealNumber
invert
public RealNumber invert()
- Overrides:
- invert in class AbstractRealNumber
add
public RealNumber add(RealNumber n)
- Overrides:
- add in class AbstractRealNumber
add
public RationalNumber add(RationalNumber n)
throws java.lang.IllegalArgumentException
- Description copied from interface:
Computes this+n, where n is a rational number.
- Specified by:
- add in interface RationalNumber
subtract
public RealNumber subtract(RealNumber n)
throws java.lang.IllegalArgumentException
- Overrides:
- subtract in class AbstractRealNumber
subtract
public RationalNumber subtract(RationalNumber n)
throws java.lang.IllegalArgumentException
- Description copied from interface:
Computes this-n, where n is a rational number.
- Specified by:
- subtract in interface RationalNumber
multiply
public RealNumber multiply(RealNumber n)
- Overrides:
- multiply in class AbstractRealNumber
multiply
public RationalNumber multiply(RationalNumber n)
throws java.lang.IllegalArgumentException
- Description copied from interface:
Computes this*n, where n is a rational number.
- Specified by:
- multiply in interface RationalNumber
divide
public RealNumber divide(RealNumber n)
throws java.lang.IllegalArgumentException,
java.lang.ArithmeticException
- Overrides:
- divide in class AbstractRealNumber
divide
public RationalNumber divide(RationalNumber n)
throws java.lang.ArithmeticException,
java.lang.IllegalArgumentException
- Description copied from interface:
Computes this/n, where n is a rational number.
- Specified by:
- divide in interface RationalNumber
pow
public RealNumber pow(RealNumber n)
throws java.lang.IllegalArgumentException
- Overrides:
- pow in class AbstractRealNumber
pow
public RationalNumber pow(IntegerNumber n)
throws java.lang.IllegalArgumentException
- Description copied from interface:
Computes this**n, where n is an integer number.
- Specified by:
- pow in interface RationalNumber
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object
doubleValue
public double doubleValue()
- Overrides:
- doubleValue in class AbstractRealNumber
toBigDecimal
public java.math.BigDecimal toBigDecimal(int precision)
throws java.lang.IllegalArgumentException
- Overrides:
- toBigDecimal in class AbstractRealNumber
toBigDecimal
public java.math.BigDecimal toBigDecimal(int precision,
int roundingMode)
throws java.lang.IllegalArgumentException
trunc
public IntegerNumber trunc()