Attributes
Members list
Type members
Classlikes
Implicit class RationalHelper to support the strings of form r"22/7", etc.
Implicit class RationalHelper to support the strings of form r"22/7", etc.
Value parameters
- sc
-
the StringContext
Attributes
- Supertypes
-
class AnyValtrait Matchableclass Any
Trait which enables Rational[N] to be used in type classes where the context type is a Fractional (or Numeric or Ordering).
Trait which enables Rational[N] to be used in type classes where the context type is a Fractional (or Numeric or Ordering).
Attributes
- Supertypes
- Known subtypes
Attributes
- Supertypes
- Known subtypes
Attributes
- Supertypes
-
class RationalIsFractionalAndFiniteNumeric[BigInt]trait RationalIsFractional[BigInt]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
Implicit objects which extend RationalIsFractional. BTW, it's OK for them to share the same name.
Implicit objects which extend RationalIsFractional. BTW, it's OK for them to share the same name.
Attributes
- Supertypes
-
class RationalIsFractionalAndFiniteNumeric[Int]trait RationalIsFractional[Int]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
Attributes
- Supertypes
-
class RationalIsFractionalAndFiniteNumeric[Long]trait RationalIsFractional[Long]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
Value members
Concrete methods
Apply method to form a Rational from a FiniteIntegral
Apply method to form a Rational from a FiniteIntegral
Value parameters
- x
-
the FiniteIntegral
Attributes
- Returns
-
the Rational corresponding to x
Apply method to form a Rational from a BigDecimal
Apply method to form a Rational from a BigDecimal
Value parameters
- x
-
the BigDecimal
Attributes
- Returns
-
the Rational corresponding to x
Apply method to form a Rational from a Double
Apply method to form a Rational from a Double
Value parameters
- x
-
the BigDecimal
Attributes
- Returns
-
the Rational corresponding to x
Apply method to form a Rational from a String
Apply method to form a Rational from a String
Value parameters
- x
-
the String
Attributes
- Returns
-
the Rational corresponding to x
Method to compare two Rational[N] numbers
Method to compare two Rational[N] numbers
Value parameters
- x
-
the first Rational[N]
- y
-
the second Rational[N]
Attributes
- Returns
-
(x-y).signum
Method to form normalized Rational[N] from the given numerator and denominator
Method to form normalized Rational[N] from the given numerator and denominator
Value parameters
- d
-
the denominator
- n
-
the numerator
Attributes
- Returns
-
a Rational[N] corresponding to n/d where n and d have no common factors
Method to add two Rational[N] objects together. The order of the parameters is immaterial.
Method to add two Rational[N] objects together. The order of the parameters is immaterial.
Value parameters
- x
-
one of the Rational[N]s
- y
-
the other Rational[N]
Attributes
- Returns
-
a new Rational[N] which is the sum of x and y
Method to multiply two Rational[N] objects together. The order of the parameters is immaterial.
Method to multiply two Rational[N] objects together. The order of the parameters is immaterial.
Value parameters
- x
-
one of the Rational[N]s
- y
-
the other Rational[N]
Attributes
- Returns
-
a new Rational[N] which is the product of x and y
Method to convert a Rational (x) into a BigInt
Method to convert a Rational (x) into a BigInt
Value parameters
- x
-
the Rational to convert
Attributes
- Returns
-
if x is whole, then the corresponding BigInt is returned.
Method to convert a Rational (x) into an Int
Method to convert a Rational (x) into an Int
Value parameters
- x
-
the Rational to convert
Attributes
- Returns
-
if x is whole and if x fits into the range of an Int, then the corresponding Int is returned; otherwise, we throw a FiniteIntegralException
Method to convert a Rational (x) into a Long
Method to convert a Rational (x) into a Long
Value parameters
- x
-
the Rational to convert
Attributes
- Returns
-
if x is whole, then the corresponding Long is returned; otherwise, we throw a FiniteIntegralException
Implicits
Implicits
Implicit class RationalHelper to support the strings of form r"22/7", etc.
Implicit class RationalHelper to support the strings of form r"22/7", etc.
Value parameters
- sc
-
the StringContext
Attributes
Implicit conversion method from Double=>Rational[N]. This is used for example when comparing a Rational[N] value with an Double
Implicit conversion method from Double=>Rational[N]. This is used for example when comparing a Rational[N] value with an Double
Value parameters
- x
-
a Double
Attributes
- Returns
-
a Rational[N] with the same value as x, or at least as close as possible
Implicit conversion method from Int=>Rational. This is used for example when comparing a Rational value with an Int
Implicit conversion method from Int=>Rational. This is used for example when comparing a Rational value with an Int
Value parameters
- x
-
an Int
Attributes
- Returns
-
a Rational with the same value as x
Implicit conversion method from Long=>Rational[N]. This is used for example when comparing a Rational[N] value with an Long
Implicit conversion method from Long=>Rational[N]. This is used for example when comparing a Rational[N] value with an Long
Value parameters
- x
-
an Long
Attributes
- Returns
-
a Rational[N] with the same value as x