Package gw.util
Class Rational
java.lang.Object
java.lang.Number
gw.util.Rational
- All Implemented Interfaces:
ISequenceable<Rational,
,Rational, Void> Serializable
,Comparable<Rational>
public final class Rational
extends Number
implements ISequenceable<Rational,Rational,Void>, Serializable
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigInteger
private final BigInteger
private boolean
static final Rational
private static final int
static final Rational
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Rational
(BigInteger numerator, BigInteger denominator, boolean reduced) -
Method Summary
Modifier and TypeMethodDescriptionabs()
add
(double d) add
(float f) add
(int i) add
(long l) add
(BigDecimal bd) add
(BigInteger bg) int
divide
(double d) divide
(float f) divide
(int i) divide
(long l) divide
(BigDecimal bd) divide
(BigInteger bi) double
boolean
float
static Rational
get
(double d) static Rational
get
(float f) static Rational
get
(int numerator) static Rational
get
(int numerator, int denominator) static Rational
get
(long numerator) static Rational
get
(long numerator, long denominator) static Rational
static Rational
get
(BigDecimal bd) static Rational
get
(BigInteger numerator) static Rational
get
(BigInteger numerator, BigInteger denominator) private static Rational
get
(BigInteger numerator, BigInteger denominator, boolean reduced) int
hashCode()
int
intValue()
invert()
private static boolean
isDecimalString
(String decimal) boolean
long
modulo
(double d) modulo
(float f) modulo
(int i) modulo
(long l) modulo
(BigDecimal bd) modulo
(BigInteger bi) multiply
(double d) multiply
(float f) multiply
(int i) multiply
(long l) multiply
(BigDecimal bd) multiply
(BigInteger bi) negate()
nextInSequence
(Rational step, Void unit) nextNthInSequence
(Rational step, Void unit, int iIndex) pow
(int exponent) previousInSequence
(Rational step, Void unit) previousNthInSequence
(Rational step, Void unit, int iIndex) reduce()
root
(int iRoot) root
(int n, int scale) int
signum()
sqrt()
subtract
(double d) subtract
(float f) subtract
(int i) subtract
(long l) subtract
(BigDecimal bd) subtract
(BigInteger bi) toString()
private Object
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
ZERO
-
ONE
-
VERSION_1
private static final int VERSION_1- See Also:
-
_numerator
-
_denominator
-
_reduced
private boolean _reduced
-
-
Constructor Details
-
Rational
-
-
Method Details
-
get
-
get
-
get
-
get
-
get
-
get
-
get
-
get
-
isDecimalString
-
get
-
get
-
get
-
reduce
-
getNumerator
-
getDenominator
-
wholePart
-
fractionPart
-
intValue
public int intValue() -
longValue
public long longValue() -
doubleValue
public double doubleValue()- Specified by:
doubleValue
in classNumber
-
floatValue
public float floatValue()- Specified by:
floatValue
in classNumber
-
toBigInteger
-
toBigDecimal
-
toBigDecimal
-
isInteger
public boolean isInteger() -
add
-
add
-
add
-
add
-
add
-
add
-
add
-
subtract
-
subtract
-
subtract
-
subtract
-
subtract
-
subtract
-
subtract
-
multiply
-
multiply
-
multiply
-
multiply
-
multiply
-
multiply
-
multiply
-
divide
-
divide
-
divide
-
divide
-
divide
-
divide
-
divide
-
modulo
-
modulo
-
modulo
-
modulo
-
modulo
-
modulo
-
modulo
-
negate
-
invert
-
abs
-
pow
-
root
-
root
-
sqrt
-
nextInSequence
- Specified by:
nextInSequence
in interfaceISequenceable<Rational,
Rational, Void>
-
nextNthInSequence
- Specified by:
nextNthInSequence
in interfaceISequenceable<Rational,
Rational, Void>
-
previousInSequence
- Specified by:
previousInSequence
in interfaceISequenceable<Rational,
Rational, Void>
-
previousNthInSequence
- Specified by:
previousNthInSequence
in interfaceISequenceable<Rational,
Rational, Void>
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Rational>
-
signum
public int signum() -
equals
-
hashCode
public int hashCode() -
toFractionString
-
toMixedString
-
toDecimalString
-
toPlainDecimalString
-
toString
-
writeReplace
-