Class RationalNumber

java.lang.Object
java.lang.Number
org.apache.commons.imaging.common.RationalNumber
All Implemented Interfaces:
Serializable

public class RationalNumber extends Number
Rational number, as used by the TIFF image format.
See Also:
  • 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

      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 class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDisplayString

      public 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