Class 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
    • Field Detail

      • numerator

        public final int numerator
      • divisor

        public final int divisor
    • Constructor Detail

      • RationalNumber

        public RationalNumber​(int numerator,
                              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
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class java.lang.Number
      • floatValue

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

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.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