Class Rational

  • All Implemented Interfaces:
    java.io.Serializable

    @Immutable
    public final class Rational
    extends java.lang.Number
    Author:
    Fabrizio Giudici
    See Also:
    Serialized Form
    • Constructor Detail

      • Rational

        public Rational()
    • Method Detail

      • of

        @Nonnull
        public static Rational of​(int i)
        Parameters:
        i -
      • of

        @Nonnull
        public static Rational of​(double d)
        Parameters:
        d -
      • doubleValue

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

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

        public byte byteValue()
        Overrides:
        byteValue 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
      • shortValue

        public short shortValue()
        Overrides:
        shortValue in class java.lang.Number
      • divide

        @Nonnull
        public Rational divide​(double det)
        Parameters:
        det -
        Returns:
      • getReciprocal

        @Nonnull
        public Rational getReciprocal()
      • isInteger

        public boolean isInteger()
      • toString

        @Nonnull
        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object