|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.charlesames.utility.math.Ratio
public class Ratio
Implements class of rational numbers; that is, numbers which can be expressed using a numerator and a denominator.
| Field Summary | |
|---|---|
static Ratio |
DUPLICITY
Ratio with numerator 2 and denominator 1. |
static Ratio |
MAX_VALUE
Ratio with numerator Long.MAX_VALUE and denominator 1. |
static Ratio |
MIN_VALUE
Ratio with numerator Long.MIN_VALUE and denominator 1. |
static java.lang.String |
REGEX
Regular expression for evaluating ratio text. |
static java.lang.String |
TYPE_NAME
XSD type name for ratio text. |
static Ratio |
UNITY
Ratio with numerator 1 and denominator 1. |
static Ratio |
ZERO
Ratio with numerator 0 and denominator 1. |
| Method Summary | |
|---|---|
Ratio |
add(long addend)
Add this ratio to the indicated long. |
Ratio |
add(Ratio addend)
Add this ratio to another ratio. |
int |
compareTo(java.lang.Object arg0)
|
static XmlType |
createXmlType()
Check if an XmlType instance exists for Ratio data. |
Ratio |
divide(long divisor)
Divide this ratio by the indicated long. |
Ratio |
divide(Ratio divisor)
Divide another ratio into this ratio. |
boolean |
equals(java.lang.Object arg)
|
boolean |
ge(Ratio other)
Test if this ratio is greater than or equal to another ratio. |
long |
getDenominator()
Get the denominator. |
static Ratio |
getInstance(long numerator,
long denominator)
Get a Ratio instance. |
long |
getNumerator()
Get the numerator. |
double |
getValue()
Get the quotient obtained by dividing the denominator into the numerator. |
boolean |
gt(Ratio other)
Test if this ratio is greater than another ratio. |
Ratio |
invert()
Invert this ratio. |
boolean |
le(Ratio other)
Test if this ratio is less than or equal to another ratio. |
boolean |
lt(Ratio other)
Test if this ratio is less than another ratio. |
Ratio |
maximum(Ratio other)
Select the maxumum of this and another Ratio. |
Ratio |
minimum(Ratio other)
Select the minimum of this and another Ratio. |
Ratio |
multiply(long factor)
Multiply this ratio by the indicated long. |
Ratio |
multiply(Ratio factor)
Multiply this ratio by another ratio. |
Ratio |
negate()
Negate this ratio. |
Ratio |
normalize()
Map this ratio into the range from . |
static Ratio |
parse(java.lang.String text)
Parse a ratio in long-colon-long format. |
Ratio |
power(long exponent)
Raise this ratio to the indicated power. |
int |
sign()
Determine whether this ratio is positive, negative, or zero. |
Ratio |
subtract(long subtrahend)
Subtract the indicated long from this ratio. |
Ratio |
subtract(Ratio subtrahend)
Subtract another ratio from this ratio. |
java.lang.String |
toString()
|
static Ratio |
valueOf(double value)
Find a Ratio with a denominator up to the indicated limit that approximates the value within 10 to the -7 power; |
static Ratio |
valueOf(double value,
int gcd)
Find the Ratio with the indicated granularity that most closely approximates the indicated value; The result is calculated by constructing a fraction with gcd as the denominator, which the Ratio constructor simplifies. |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TYPE_NAME
public static final java.lang.String REGEX
public static final Ratio ZERO
public static final Ratio UNITY
public static final Ratio DUPLICITY
public static final Ratio MAX_VALUE
public static final Ratio MIN_VALUE
| Method Detail |
|---|
public static Ratio getInstance(long numerator,
long denominator)
Ratio instance.
numerator - The long integer on top of the fraction.denominator - The long integer on the bottom of the fraction.
The greatest common denominator of the numerator and the denominator is divided out of both numbers.
If the denominator is negative, the numerator and denominator signs are flipped.
Ratio representing the quotient of the numerator and the denominator, reduced to simplest terms.public static XmlType createXmlType()
XmlType instance exists for Ratio data.
If not, create one.
XmlType instance for Ratio data.public long getNumerator()
public long getDenominator()
public double getValue()
public Ratio add(Ratio addend)
addend - The other ratio.
public Ratio add(long addend)
addend - The indicated long.
public Ratio negate()
public Ratio normalize()
public Ratio subtract(Ratio subtrahend)
subtrahend - The other ratio.
public Ratio subtract(long subtrahend)
subtrahend - The indicated long.
public Ratio invert()
public Ratio multiply(Ratio factor)
factor - The other ratio.
public Ratio multiply(long factor)
factor - The indicated long.
public Ratio divide(Ratio divisor)
divisor - The other ratio.
public Ratio divide(long divisor)
divisor - The indicated long.
public Ratio power(long exponent)
exponent - The indicated power. Must not be negative.
public java.lang.String toString()
toString in class java.lang.Objectpublic static Ratio parse(java.lang.String text)
text - The source text.
public static Ratio valueOf(double value)
value - The input.
public static Ratio valueOf(double value,
int gcd)
Ratio constructor simplifies.
value - The input.gcd - The indicated granularity.
Ratio approximating the input.public int sign()
public int compareTo(java.lang.Object arg0)
compareTo in interface java.lang.Comparable<java.lang.Object>public boolean gt(Ratio other)
other - The other ratio.
public boolean ge(Ratio other)
other - The other ratio.
public boolean lt(Ratio other)
other - The other ratio.
public boolean le(Ratio other)
other - The other ratio.
public Ratio minimum(Ratio other)
Ratio.
other - The other Ratio.
Ratio.public Ratio maximum(Ratio other)
Ratio.
other - The other Ratio.
Ratio.public boolean equals(java.lang.Object arg)
equals in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||