Rational
Edit on GitHubUtilities for working with the Rational type.
Added in 0.6.0
No other changes yet.
Values
Functions and constants included in the Rational module.
Rational.fromNumber
Added in 0.6.0
No other changes yet.
Converts a Number to a Rational.
Parameters:
param | type | description |
---|---|---|
number |
Number |
The value to convert |
Returns:
type | description |
---|---|
Rational |
The Number represented as a Rational |
Rational.toNumber
Added in 0.6.0
No other changes yet.
Converts a Rational to a Number.
Parameters:
param | type | description |
---|---|---|
rational |
Rational |
The value to convert |
Returns:
type | description |
---|---|
Number |
The Rational represented as a Number |
Rational.numerator
Added in 0.6.0
No other changes yet.
Finds the numerator of the rational number.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The rational number to inspect |
Returns:
type | description |
---|---|
Number |
The numerator of the rational number |
Rational.denominator
Added in 0.6.0
No other changes yet.
Finds the denominator of the rational number.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The rational number to inspect |
Returns:
type | description |
---|---|
Number |
The denominator of the rational number |
Rational.toIntegerRatio
Added in 0.6.0
No other changes yet.
Gets the numerator and denominator of the rational.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The rational to split |
Returns:
type | description |
---|---|
(Number, Number) |
The numerator and denominator of the rational |
Examples:
Rational.fromIntegerRatio
Added in 0.6.0
No other changes yet.
Creates a rational from a numerator and denominator.
Parameters:
param | type | description |
---|---|---|
numerator |
Number |
The numerator |
denominator |
Number |
The denominator |
Returns:
type | description |
---|---|
Rational |
The reduced rational |
Throws:
InvalidArgument(String)
- If the numerator is not an integer
- If the denominator is not an integer
Examples:
Rational.(+)
Added in 0.6.0
No other changes yet.
Computes the sum of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first operand |
y |
Rational |
The second operand |
Returns:
type | description |
---|---|
Rational |
The sum of the two operands |
Examples:
Rational.(-)
Added in 0.6.0
No other changes yet.
Computes the difference of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first operand |
y |
Rational |
The second operand |
Returns:
type | description |
---|---|
Rational |
The difference of the two operands |
Examples:
Rational.(*)
Added in 0.6.0
No other changes yet.
Computes the product of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first operand |
y |
Rational |
The second operand |
Returns:
type | description |
---|---|
Rational |
The product of the two operands |
Examples:
Rational.(/)
Added in 0.6.0
No other changes yet.
Computes the quotient of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first operand |
y |
Rational |
The second operand |
Returns:
type | description |
---|---|
Rational |
The quotient of the two operands |
Examples:
Rational.(==)
Added in 0.6.0
No other changes yet.
Checks if the first value is equal to the second value.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first value |
y |
Rational |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is equal to the second value or false otherwise |
Examples:
Rational.(!=)
Added in 0.6.0
No other changes yet.
Checks if the first value is not equal to the second value.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first value |
y |
Rational |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is not equal to the second value or false otherwise |
Examples:
Rational.(<)
Added in 0.6.0
No other changes yet.
Checks if the first value is less than the second value.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first value |
y |
Rational |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is less than the second value or false otherwise |
Examples:
Rational.(>)
Added in 0.6.0
No other changes yet.
Checks if the first value is greater than the second value.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first value |
y |
Rational |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is greater than the second value or false otherwise |
Examples:
Rational.(<=)
Added in 0.6.0
No other changes yet.
Checks if the first value is less than or equal to the second value.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first value |
y |
Rational |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is less than or equal to the second value or false otherwise |
Examples:
Rational.(>=)
Added in 0.6.0
No other changes yet.
Checks if the first value is greater than or equal to the second value.
Parameters:
param | type | description |
---|---|---|
x |
Rational |
The first value |
y |
Rational |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is greater than or equal to the second value or false otherwise |
Examples: