Class RationalNumber
java.lang.Object
java.lang.Number
org.apache.commons.imaging.common.RationalNumber
- All Implemented Interfaces:
Serializable
Rational number, as used by the TIFF image format.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intfinal intprivate static final longprivate static final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble(package private) static RationalNumberfactoryMethod(long n, long d) floatprivate static longgcd(long a, long b) Return the greatest common divisorintintValue()longnegate()toString()static RationalNumbervalueOf(double value) Calculate rational number using successive approximations.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
TOLERANCE
private static final double TOLERANCE- See Also:
-
numerator
public final int numerator -
divisor
public final int divisor
-
-
Constructor Details
-
RationalNumber
public RationalNumber(int numerator, int divisor)
-
-
Method Details
-
factoryMethod
-
gcd
private static long gcd(long a, long b) Return the greatest common divisor -
negate
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
intValue
public int intValue() -
longValue
public long longValue() -
toString
-
toDisplayString
-
valueOf
Calculate rational number using successive approximations.- Parameters:
value- rational number double value- Returns:
- the RationalNumber representation of the double value
-