org.lsmp.djep.groupJep.values
Class Rational
java.lang.Object
java.lang.Number
org.lsmp.djep.groupJep.values.Rational
- All Implemented Interfaces:
- Serializable, Comparable
public class Rational
- extends Number
- implements Comparable
A Rational number with full precision. Represented as quotien of two
numbers (always in most reduced form with posative denominator).
- Author:
- Rich Morris
Created on 05-Mar-2004
- See Also:
- Serialized Form
Rational
public Rational(BigInteger num)
Rational
public Rational(BigInteger num,
BigInteger den)
- Rationals will always be represented in most reduced
form with a positive denominator.
intValue
public int intValue()
- Specified by:
intValue in class Number
longValue
public long longValue()
- Specified by:
longValue in class Number
floatValue
public float floatValue()
- Specified by:
floatValue in class Number
doubleValue
public double doubleValue()
- Specified by:
doubleValue in class Number
add
public Rational add(Rational arg)
sub
public Rational sub(Rational arg)
mul
public Rational mul(Rational arg)
div
public Rational div(Rational arg)
pow
public Rational pow(Rational arg)
negate
public Rational negate()
inverse
public Rational inverse()
valueOf
public static Number valueOf(String s)
getDenominator
public BigInteger getDenominator()
- * Returns the bottom half of the rational.
getNumerator
public BigInteger getNumerator()
- Returns the top half of the rational.
toString
public String toString()
- Overrides:
toString in class Object
compareTo
public int compareTo(Object arg)
- Specified by:
compareTo in interface Comparable
Copyright © 2014. All rights reserved.