Class IntFraction

java.lang.Object
eu.bandm.sig.adlib2.IntFraction
All Implemented Interfaces:
Comparable<IntFraction>

public class IntFraction extends Object implements Comparable<IntFraction>
Representation of fractions.

A fraction is a pair of values, namely the numerator and the denominator, respectively, and represents their quotient.

This class provides fractional arithmetic operations. Note that those are not optimized for high performance or low memory usage. Thus, computations implemented by this class should be used only at construction time of a network. For realtime fractional computations, use IntSignalSourceFraction instead.

  • Field Details

    • ZERO

      public static final IntFraction ZERO
      The fractional representation of the number zero.
    • ONE

      public static final IntFraction ONE
      The fractional representation of the number one.
    • POSITIVE_INFINITY

      public static final IntFraction POSITIVE_INFINITY
      The fractional representation of positive infinity.
    • NEGATIVE_INFINITY

      public static final IntFraction NEGATIVE_INFINITY
      The fractional representation of negative infinity.
    • NOT_A_NUMBER

      public static final IntFraction NOT_A_NUMBER
      The fractional representation of an undefined quantity.
  • Constructor Details

    • IntFraction

      public IntFraction(int numerator, int denominator)
  • Method Details

    • getNumerator

      public int getNumerator()
      Returns the numerator of this fraction.
    • getDenominator

      public int getDenominator()
      Returns the denominator of this fraction.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

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

      public IntFraction reciprocal()
      Returns the formal reciprocal of this fraction.
      Returns:
      a fraction where numerator and denominator are exchanged
    • floatValue

      public float floatValue()
    • doubleValue

      public double doubleValue()
    • isNaN

      public boolean isNaN()
    • compareTo

      public int compareTo(IntFraction other)
      Specified by:
      compareTo in interface Comparable<IntFraction>
    • signum

      public int signum()
    • add

      public IntFraction add(IntFraction other)
    • subtract

      public IntFraction subtract(IntFraction other)
    • multiply

      public IntFraction multiply(IntFraction other)
    • divide

      public IntFraction divide(IntFraction other)
    • negate

      public IntFraction negate()