public class Rational extends Object
Constructor and Description |
---|
Rational(int numerator,
int denominator)
The arguments to the int constructor are treated as
32-bit unsigned integers.
|
Rational(long numerator,
long denominator)
The arguments to this constructor are long in order to
represent all possible 32-bit unsigned integers.
|
Modifier and Type | Method and Description |
---|---|
long |
getDenominator()
Returns the Denominator property.
|
long |
getNumerator()
Returns the Numerator property.
|
double |
toDouble()
Converts to a floating-point value (numerator/denominator).
|
long |
toLong()
Converts to a long value (numerator/denominator).
|
String |
toString()
Represents the Rational as a String in the form of
"numerator/denominator".
|
public Rational(long numerator, long denominator)
numerator
- numerator of the Rational valuedenominator
- denominator of the Rational valuepublic Rational(int numerator, int denominator)
numerator
- numerator of the Rational valuedenominator
- denominator of the Rational valuepublic long getNumerator()
public long getDenominator()
public double toDouble()
public long toLong()
Copyright © 2008–2017 The Open Preservation Foundation. All rights reserved.