public interface Rational
Specifies a rational number by means of a Java integer numerator (Int32) and a
Java integer (Int32) denominator.
To make values of this type, use the following methods from the MAJ forge:
Forge.makeRational(int, int);Forge.zeroRational();toString():
Forge.parseRational(String).TypeDefinitions.Rational| Modifier and Type | Method and Description |
|---|---|
Rational |
clone()
Create a cloned copy of this rational value.
|
double |
doubleValue()
Returns the value of this rational as a Java double.
|
int |
getDenominator()
Returns the denominator of the value represented by this rational number.
|
int |
getNumerator()
Returns the numerator of the value represented by this rational number.
|
void |
setDenominator(int denominator)
Sets the denominator of the value represented by this rational number.
|
void |
setNumerator(int numerator)
Sets the numerator of the value represented by this rational number.
|
void |
setRational(int numerator,
int denominator)
Set the value of this rational number with both its numerator and denominator.
|
String |
toString()
Formats a string representation of this rational value as the numerator, followed by a
slash (/), followed by the denominator.
|
@Int32 int getNumerator()
Returns the numerator of the value represented by this rational number.
void setNumerator(@Int32 int numerator)
Sets the numerator of the value represented by this rational number.
numerator - Numerator part of the rational value.@Int32 int getDenominator()
Returns the denominator of the value represented by this rational number.
void setDenominator(@Int32 int denominator)
Sets the denominator of the value represented by this rational number.
denominator - Denominator part of the rational value.void setRational(@Int32 int numerator, @Int32 int denominator)
Set the value of this rational number with both its numerator and denominator.
numerator - Numerator part of the rational value.denominator - Denominator part of the rational value.Rational clone()
Create a cloned copy of this rational value.
double doubleValue()
Returns the value of this rational as a Java double.
String toString()
Formats a string representation of this rational value as the numerator, followed by a
slash (/), followed by the denominator. For example, "1/4". The format is the same as that
parsed by Forge.parseRational(String).
toString in class ObjectForge.parseRational(String)(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.