The Rat companion object defines the origin (zero), one and minus one as well as some utility functions.
Attributes
Members list
Type members
Inherited and Abstract types
The names of the product elements.
The names of the product elements.
Attributes
- Inherited from:
- Mirror
The name of the type.
The name of the type.
Attributes
- Inherited from:
- Mirror
Value members
Concrete methods
Return the absolute value of that rational number.
Return the absolute value of that rational number.
Value parameters
- x
-
that rational number
Attributes
Create a rational number from a pair of Longs.
Create a rational number from a pair of Longs.
Value parameters
- qt
-
the tuple form of a rational number
Attributes
Create a rational number from its primary string representation "a/b". Examples: "2/3", "2".
Create a rational number from its primary string representation "a/b". Examples: "2/3", "2".
Value parameters
- qs
-
the string form of a rational number
Attributes
Create a rational number from its secondary string representation "(a, b)". Examples: "(2, 3)", "(2, 1)".
Create a rational number from its secondary string representation "(a, b)". Examples: "(2, 3)", "(2, 1)".
Value parameters
- qs
-
the string form of a rational number
Attributes
Create a rational number from a BigDecimal number.
Create a rational number from a BigDecimal number.
Value parameters
- md
-
the maximum denominator
- y
-
the
BigDecimalused to create the rational number
Attributes
Create a rational number from a Double.
Create a rational number from a Double.
Value parameters
- md
-
the maximum denominator
- y
-
the double used to create the rational number
Attributes
Create a rational number from a Double. FIX: if den not a power of 2, it goes to 'md'.
Create a rational number from a Double. FIX: if den not a power of 2, it goes to 'md'.
Value parameters
- md
-
the maximum denominator
- y
-
the double used to create the rational number.
Attributes
- See also
Create a rational number with a small odd denominator from a Double y by running through possible odd denominators d from 1 to max_d and creating two candidate numerators n for each d, one with n/d below and other above.
Create a rational number with a small odd denominator from a Double y by running through possible odd denominators d from 1 to max_d and creating two candidate numerators n for each d, one with n/d below and other above.
Value parameters
- y
-
the double used to create the rational number.
Attributes
Create a rational number from a Float.
Create a rational number from a Float.
Value parameters
- y
-
the float used to create the rational number.
Attributes
Create a rational number from an Int.
Create a rational number from an Int.
Value parameters
- n
-
the integer used to create the rational number.
Attributes
Create a rational number from a Long.
Create a rational number from a Long.
Value parameters
- n
-
the long used to create the rational number.
Attributes
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.
Value parameters
- md
-
the maximum denominator
- y
-
the
BigDecimalused to create the rational number
Attributes
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.
Value parameters
- md
-
the maximum denominator
- y
-
the double used to create the rational number
Attributes
- See also
-
http://stackoverflow.com/questions/5124743/algorithm-for-simplifying- decimal-to-fractions/5128558#5128558
Make a rational number from a String of the form "12.3E+7".
Make a rational number from a String of the form "12.3E+7".
Value parameters
- s
-
the given String representation of a number
Attributes
- See also
-
http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html #BigDecimal%28java.lang.String%29
Return the maximum of two rational numbers, q and p.
Return the maximum of two rational numbers, q and p.
Value parameters
- p
-
the second rational number to compare
- q
-
the first rational number to compare
Attributes
Return the minimum of two rational numbers, q and p.
Return the minimum of two rational numbers, q and p.
Value parameters
- p
-
the second rational number to compare
- q
-
the first rational number to compare
Attributes
Return the signum (sgn) of a rational number. The values may be -1, 0, or 1.
Return the signum (sgn) of a rational number. The values may be -1, 0, or 1.
Value parameters
- r
-
the rational number to obtain the sigum of
Attributes
Concrete fields
One in BigDecimal
One in BigDecimal
Attributes
Denominator (2 ~^ 54) big enough to capture largest Double significand (53 bits)
Denominator (2 ~^ 54) big enough to capture largest Double significand (53 bits)