@Immutable public final class Rational extends Number implements Comparable<Rational>
Modifier and Type | Method and Description |
---|---|
Rational |
abs()
Returns the absolute value of this number.
|
Rational |
add(long integer)
Adds an integer.
|
Rational |
add(Rational other)
Adds an other rational.
|
int |
compareTo(Rational other) |
Rational |
divide(long integer)
Divides by an integer.
|
Rational |
divide(Rational other)
Divides by an other rational.
|
double |
doubleValue() |
boolean |
equals(Object object) |
float |
floatValue() |
long |
getDenominator()
Gets the denominator.
|
long |
getNumerator()
Gets the numerator.
|
int |
hashCode() |
int |
intValue() |
long |
longValue() |
Rational |
multiply(long integer)
Multiplies by an integer.
|
Rational |
multiply(Rational other)
Multiplies by an other rational.
|
Rational |
negate()
Negates this number.
|
Rational |
reciprocal()
Returns the reciprocal value of this number.
|
int |
signum()
Returns the signum function of this number.
|
Rational |
subtract(long integer)
Subtracts an integer.
|
Rational |
subtract(Rational other)
Subtracts an other rational.
|
String |
toString() |
static Rational |
valueOf(long numerator,
long denominator)
Returns a rational number having the values specified.
|
static Rational |
valueOf(String string)
Returns a rational number from the value of a string.
|
@Nonnull @CheckReturnValue public static Rational valueOf(@Nonnull String string)
string
- The string.@Nonnull @CheckReturnValue public static Rational valueOf(long numerator, long denominator)
numerator
- The numerator.denominator
- The denominator.@Nonnull @CheckReturnValue public Rational abs()
@Nonnull @CheckReturnValue public Rational add(long integer)
integer
- The (long) integer.@Nonnull @CheckReturnValue public Rational add(@Nonnull Rational other)
other
- The other rational.public int compareTo(Rational other)
compareTo
in interface Comparable<Rational>
@Nonnull @CheckReturnValue public Rational divide(long integer)
integer
- The (long) integer.@Nonnull @CheckReturnValue public Rational divide(@Nonnull Rational other)
other
- The other rational.public double doubleValue()
doubleValue
in class Number
public boolean equals(Object object)
equals
in class Object
public float floatValue()
floatValue
in class Number
@CheckReturnValue public long getDenominator()
@CheckReturnValue public long getNumerator()
public int hashCode()
hashCode
in class Object
public int intValue()
intValue
in class Number
public long longValue()
longValue
in class Number
@Nonnull @CheckReturnValue public Rational multiply(long integer)
integer
- The (long) integer.@Nonnull @CheckReturnValue public Rational multiply(@Nonnull Rational other)
other
- The other rational.@Nonnull @CheckReturnValue public Rational negate()
@Nonnull @CheckReturnValue public Rational reciprocal()
@CheckReturnValue public int signum()
@Nonnull @CheckReturnValue public Rational subtract(long integer)
integer
- The (long) integer.@Nonnull @CheckReturnValue public Rational subtract(@Nonnull Rational other)
other
- The other rational.public String toString()
toString
in class Object
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.