Class RationalNumber
- java.lang.Object
-
- java.lang.Number
-
- org.apache.commons.imaging.common.RationalNumber
-
- All Implemented Interfaces:
java.io.Serializable
public class RationalNumber extends java.lang.Number
Rational number, as used by the TIFF image format.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RationalNumber.Option
-
Field Summary
Fields Modifier and Type Field Description int
divisor
int
numerator
private static long
serialVersionUID
private static double
TOLERANCE
-
Constructor Summary
Constructors Constructor Description RationalNumber(int numerator, int divisor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
doubleValue()
(package private) static RationalNumber
factoryMethod(long n, long d)
float
floatValue()
private static long
gcd(long a, long b)
Return the greatest common divisorint
intValue()
long
longValue()
RationalNumber
negate()
java.lang.String
toDisplayString()
java.lang.String
toString()
static RationalNumber
valueOf(double value)
Calculate rational number using successive approximations.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
TOLERANCE
private static final double TOLERANCE
- See Also:
- Constant Field Values
-
numerator
public final int numerator
-
divisor
public final int divisor
-
-
Method Detail
-
factoryMethod
static RationalNumber factoryMethod(long n, long d)
-
gcd
private static long gcd(long a, long b)
Return the greatest common divisor
-
negate
public RationalNumber negate()
-
doubleValue
public double doubleValue()
- Specified by:
doubleValue
in classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValue
in classjava.lang.Number
-
intValue
public int intValue()
- Specified by:
intValue
in classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValue
in classjava.lang.Number
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toDisplayString
public java.lang.String toDisplayString()
-
valueOf
public static RationalNumber valueOf(double value)
Calculate rational number using successive approximations.- Parameters:
value
- rational number double value- Returns:
- the RationalNumber representation of the double value
-
-