public class Rational extends java.lang.Number implements java.lang.Comparable<Rational>
| Modifier and Type | Field and Description |
|---|---|
static Rational |
HALF |
static Rational |
MINUSONE |
static Rational |
ONE |
static Rational |
TWO |
static Rational |
ZERO |
| Constructor and Description |
|---|
Rational()
Zero
|
Rational(java.math.BigInteger val) |
Rational(java.math.BigInteger num,
java.math.BigInteger denom) |
Rational(int numerator) |
Rational(int numerator,
int denominator) |
Rational(long numerator) |
| Modifier and Type | Method and Description |
|---|---|
Rational |
add(Rational r) |
int |
compareTo(Rational num) |
Rational |
div(Rational r) |
double |
doubleValue() |
boolean |
equals(java.lang.Object obj) |
float |
floatValue() |
java.math.BigInteger |
getDenominator() |
java.math.BigInteger |
getNumerator() |
int |
hashCode() |
int |
intValue() |
long |
longValue() |
Rational |
mul(Rational r) |
Rational |
neg() |
Rational |
sub(Rational r) |
java.lang.String |
toString() |
static Rational |
valueOf(int a) |
static Rational |
valueOf(int a,
int b) |
static Rational |
valueOf(long a) |
public static final Rational ZERO
public static final Rational ONE
public static final Rational TWO
public static final Rational MINUSONE
public static final Rational HALF
public Rational()
public Rational(int numerator,
int denominator)
denominator - numerator - public Rational(int numerator)
public Rational(java.math.BigInteger num,
java.math.BigInteger denom)
public Rational(long numerator)
public Rational(java.math.BigInteger val)
public java.math.BigInteger getNumerator()
public java.math.BigInteger getDenominator()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic Rational neg()
public int compareTo(Rational num)
compareTo in interface java.lang.Comparable<Rational>public static Rational valueOf(int a)
public static Rational valueOf(long a)
public static Rational valueOf(int a, int b)
public int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic double doubleValue()
doubleValue in class java.lang.NumberCopyright © 2018 Singular Systems http://www.singularsys.com/jep