scalation.math

Rational

object Rational extends Serializable

This companion object defines the origin (zero), one and minus one as well as some utility functions.

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Rational
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. val _0: Rational

    Zero (0) as a Rational number

  7. val _1: Rational

    One (1) as a Rational number

  8. val _1_big: BigDecimal

    One in BigDecimal

  9. val _1n: Rational

    Negative one (-1) as a Rational number

  10. def abs(x: Rational): Rational

    Return the absolute value of that rational number.

    Return the absolute value of that rational number.

    x

    that rational number

  11. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  12. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  16. def fromBigDecimal(y: BigDecimal): Rational

    Create a rational number from a BigDecimal number.

    Create a rational number from a BigDecimal number.

    y

    the BigDecimal used to create the rational number

  17. def fromDouble(y: Double): Rational

    Create a rational number from a double.

    Create a rational number from a double.

    y

    the double used to create the rational number

  18. def fromDouble2(y: Double, md: Long = maxDen): Rational

    Create a rational number from a Double.

    Create a rational number from a Double. FIX: if den not a power of 2, it goes to md.

    y

    the double used to create the rational number.

    md

    the maximum denominator

    See also

    http://rosettacode.org/wiki/Convert_decimal_number_to_rational

  19. def fromFloat(y: Float): Rational

    Create a rational number from a Float.

    Create a rational number from a Float.

    y

    the float used to create the rational number.

  20. def fromInt(n: Int): Rational

    Create a rational number from an Int.

    Create a rational number from an Int.

    n

    the integer used to create the rational number.

  21. def fromLong(n: Long): Rational

    Create a rational number from a Long.

    Create a rational number from a Long.

    n

    the long used to create the rational number.

  22. def from_BigDecimal(y: BigDecimal, md: Long = Long.MaxValue): (Long, Long)

    Determine the numerator and denonimator of the closest rational number to the given BigDecimal number.

    Determine the numerator and denonimator of the closest rational number to the given BigDecimal number.

    y

    the BigDecimal used to create the rational number

    md

    the maximum denominator

  23. def from_Double(y: Double, md: Long = maxDen): (Long, Long)

    Determine the numerator and denonimator of the closest rational number to the given BigDecimal number.

    Determine the numerator and denonimator of the closest rational number to the given BigDecimal number.

    y

    the double used to create the rational number

    md

    the maximum denominator

    See also

    http://stackoverflow.com/questions/5124743/algorithm-for-simplifying- decimal-to-fractions/5128558#5128558

  24. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  25. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  26. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  27. val maxDen: Long

    Denominator (2 ~^ 54) big enough to capture largest Double significand (53 bits)

  28. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  29. final def notify(): Unit

    Definition Classes
    AnyRef
  30. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  31. val ord: Ordering[Rational]

    Ordering for rational numbers.

  32. def readResolve(): AnyRef

    Attributes
    protected
  33. def sqrt(x: Rational): Rational

    Return the square root of that rational number.

    Return the square root of that rational number.

    x

    that rational number

  34. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  35. def toString(): String

    Definition Classes
    AnyRef → Any
  36. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  37. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  38. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any