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.NumberRational number, as used by the TIFF image format.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classRationalNumber.Option
-
Field Summary
Fields Modifier and Type Field Description intdivisorintnumeratorprivate static longserialVersionUIDprivate static doubleTOLERANCE
-
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 doubledoubleValue()(package private) static RationalNumberfactoryMethod(long n, long d)floatfloatValue()private static longgcd(long a, long b)Return the greatest common divisorintintValue()longlongValue()RationalNumbernegate()java.lang.StringtoDisplayString()java.lang.StringtoString()static RationalNumbervalueOf(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:
doubleValuein classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValuein classjava.lang.Number
-
intValue
public int intValue()
- Specified by:
intValuein classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValuein classjava.lang.Number
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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
-
-