Class Rational

java.lang.Object
edu.harvard.hul.ois.jhove.Rational

public class Rational extends Object
This class encapsulates a number which is defined as the ratio of two 32-bit unsigned integers, in accordance with the TIFF specification.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rational(int numerator, int denominator)
    The arguments to the int constructor are treated as 32-bit unsigned integers.
    Rational(long numerator, long denominator)
    The arguments to this constructor are long in order to represent all possible 32-bit unsigned integers.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the Denominator property.
    long
    Returns the Numerator property.
    double
    Converts to a floating-point value (numerator/denominator).
    long
    Converts to a long value (numerator/denominator).
    Represents the Rational as a String in the form of "numerator/denominator".

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Rational

      public Rational(long numerator, long denominator)
      The arguments to this constructor are long in order to represent all possible 32-bit unsigned integers. Parameters greater than 2 ^ 32 - 1 are not meaningful.
      Parameters:
      numerator - numerator of the Rational value
      denominator - denominator of the Rational value
    • Rational

      public Rational(int numerator, int denominator)
      The arguments to the int constructor are treated as 32-bit unsigned integers.
      Parameters:
      numerator - numerator of the Rational value
      denominator - denominator of the Rational value
  • Method Details

    • getNumerator

      public long getNumerator()
      Returns the Numerator property.
    • getDenominator

      public long getDenominator()
      Returns the Denominator property.
    • toDouble

      public double toDouble()
      Converts to a floating-point value (numerator/denominator). May throw an ArithmeticException.
    • toLong

      public long toLong()
      Converts to a long value (numerator/denominator). May throw an ArithmeticException.
    • toString

      public String toString()
      Represents the Rational as a String in the form of "numerator/denominator".
      Overrides:
      toString in class Object