Class: bigrat

bigrat

Arbitrary Sized Rational Number

Constructor

new bigrat()

Source:
Requires:
  • module:bigint

Requires

  • module:bigint

Members

(static, readonly) EPSILON

Machine Epsilon, floats within this distance of each other are considered equal
Properties:
Name Type Description
EPSILON
Source:

(static, readonly) INFINITESIMAL

Infinitesimal, the limit for approximations
Properties:
Name Type Description
INFINITESIMAL
Source:

(static, readonly) INFINITY

Infinity, a non-Zero number divided by Zero
Properties:
Name Type Description
INFINITY
Source:

(static, readonly) INFINULL

Infinull, Zero divided by Zero
Properties:
Name Type Description
INFINULL
Source:

(static, readonly) MAX_LOOPS

Exit (possibly infinite) loops after this many iterations
Properties:
Name Type Description
MAX_LOOPS
Source:

(static, readonly) NEGONE

Negative One, Zero minus One
Properties:
Name Type Description
NEGONE
Source:

(static, readonly) ONE

One, the multiplicative identity
Properties:
Name Type Description
ONE
Source:

(static, readonly) PI

Pi, an approximation of the ratio between a circle's circumference and it's diameter
Properties:
Name Type Description
PI
Source:

(static, readonly) ZERO

Zero, the additive identity
Properties:
Name Type Description
ZERO
Source:

Methods

(static) abs(out, a) → {bigrat}

Absolute value of a bigrat
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number to take the absolute value of
Source:
Returns:
out
Type
bigrat

(static) add(out, a, b) → {bigrat}

Adds two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out
Type
bigrat

(static) approximates(a, b) → {Bool}

Returns true when the first bigrat is approximately equal to the second
Parameters:
Name Type Description
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
true when the difference between the two bigrats is less than bigrat.INFINITESIMAL
Type
Bool

(static) ceil(a) → {Integer}

Returns the closest integer approximation by rounding up
Parameters:
Name Type Description
a bigrat number to round up to the nearest integer
Source:
Returns:
integer approximation of the number
Type
Integer

(static) clone(a) → {bigrat}

Creates a new bigrat initialized with values from an existing number
Parameters:
Name Type Description
a bigrat number to clone
Source:
Returns:
a new bigrational number
Type
bigrat

(static) copy(out, a) → {bigrat}

Copy the values from one bigrat to another
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the source number
Source:
Returns:
out
Type
bigrat

(static) cos(out, a) → {bigrat}

Parametric cosine: (1 - a²) / (1 + a²)
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number for which to calculate the parametric cosine
Source:
Returns:
out
Type
bigrat

(static) create() → {bigrat}

Creates a new, empty bigrat
Source:
Returns:
a new bigrational number
Type
bigrat

(static) dec()

Alias for bigrat.toDecimal
Source:

(static) div()

Alias for bigrat.divide
Source:

(static) divide(out, a, b) → {bigrat}

Divides two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out
Type
bigrat

(static) dot(a, b) → {Integer}

Calculates the dot product of two bigrats
Parameters:
Name Type Description
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
dot product of a and b
Type
Integer

(static) dump(a) → {String}

Returns a string with the fraction in various formats
Parameters:
Name Type Description
a bigrat number to dump
Source:
Returns:
string various conversions
Type
String

(static) equals(a, b) → {Bool}

Returns true when the first bigrat is equal to the second
Parameters:
Name Type Description
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
true when the two bigrats are equal
Type
Bool

(static) floor(a) → {Integer}

Returns the closest integer approximation by rounding down
Parameters:
Name Type Description
a bigrat number to round down to the nearest integer
Source:
Returns:
integer approximation of the number
Type
Integer

(static) fromContinuedFraction(out, integers) → {bigrat}

Returns a bigrat from an array of integers representing a continued fraction
Parameters:
Name Type Description
out bigrat the receiving number
integers Array of the continued fraction
Source:
Returns:
out
Type
bigrat

(static) fromDecimal(a) → {bigrat}

Returns a bigrat from a decimal number, creating a new bigrat
Parameters:
Name Type Description
a Number decimal number
Source:
Returns:
out
Type
bigrat

(static) fromDecimal_copy(out, a) → {bigrat}

Returns a bigrat from a decimal number, copying to an existing bigrat
Parameters:
Name Type Description
out bigrat the receiving number
a Number decimal number
Source:
Returns:
out
Type
bigrat

(static) fromFactorial(out, n) → {bigrat}

Return the factorial of n as a big rational number
Parameters:
Name Type Description
out bigrat the receiving number
n Integer
Source:
Returns:
factorial of n
Type
bigrat

(static) fromInteger(signed) → {bigrat}

Returns a bigrat from an integer, creating a new bigrat
Parameters:
Name Type Description
signed Integer integer
Source:
Returns:
out
Type
bigrat

(static) fromInteger_copy(out, signed) → {bigrat}

Returns a bigrat from an integer, copying to an existing bigrat
Parameters:
Name Type Description
out bigrat the receiving number
signed Integer integer
Source:
Returns:
out
Type
bigrat

(static) fromIntegerInverse(signed) → {bigrat}

Returns a bigrat from the inverse of an integer, creating a new bigrat
Parameters:
Name Type Description
signed Integer integer
Source:
Returns:
out
Type
bigrat

(static) fromIntegerInverse_copy(out, signed) → {bigrat}

Returns a bigrat from the inverse of an integer, copying to an existing bigrat
Parameters:
Name Type Description
out bigrat the receiving number
signed Integer integer
Source:
Returns:
out
Type
bigrat

(static) fromRandom(out) → {bigrat}

Creates a new bigrat from two random integers
Parameters:
Name Type Description
out bigrat the receiving number
Source:
Returns:
a random bigrational number
Type
bigrat

(static) fromRat(out, a) → {bigrat}

Returns a bigrat from a rat
Parameters:
Name Type Description
out bigrat the receiving number
a rat number to convert
Source:
Returns:
out
Type
bigrat

(static) fromValues(n, d) → {bigrat}

Creates a new bigrat initialized with the given values
Parameters:
Name Type Description
n Number Numerator
d Number Denominator
Source:
Returns:
a new bigrational number
Type
bigrat

(static) invert(out, a) → {bigrat}

Inverts a bigrat
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number to invert
Source:
Returns:
out
Type
bigrat

(static) isGreaterThan(a, b) → {Bool}

Returns true when the first bigrat is larger than the second
Parameters:
Name Type Description
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
true when the first operand is larger
Type
Bool

(static) isLessThan(a, b) → {Bool}

Returns true when the first bigrat is smaller than the second
Parameters:
Name Type Description
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
true when the first operand is smaller
Type
Bool

(static) isNegative(a) → {Bool}

Returns true when the bigrat is negative
Parameters:
Name Type Description
a bigrat the number to check
Source:
Returns:
true when the number is less than zero
Type
Bool

(static) max(out, a, b) → {bigrat}

Returns the maximum of two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out
Type
bigrat

(static) mediant(out, a, b) → {bigrat}

Mediant of two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out the sum of the numerators divided by the sum of the denominators
Type
bigrat

(static) min(out, a, b) → {bigrat}

Returns the minimum of two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out
Type
bigrat

(static) mul()

Alias for bigrat.multiply
Source:

(static) multiply(out, a, b) → {bigrat}

Multiplies two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out
Type
bigrat

(static) neg()

Alias for bigrat.opposite
Source:

(static) negative()

Alias for bigrat.opposite
Source:

(static) normalize(out, a) → {bigrat}

Normalize a bigrat
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number to normalize
Source:
Returns:
out
Type
bigrat

(static) nthRoot(out, a, n) → {bigrat}

Find a bigrat approximation which equals the input bigrat when raised to the given integer exponent Newton's method converges alot faster... could that be used to find the pattern in the SB tree?
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the number to find the root of
n Integer
Source:
Returns:
out
Type
bigrat

(static) opposite(out, a) → {bigrat}

Negates a bigrat
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number to negate
Source:
Returns:
out
Type
bigrat

(static) pow()

Alias for bigrat.power
Source:

(static) power(out, a, p) → {bigrat}

Raises a bigrat to an integer exponent
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the number to exponentiate
p Integer power to raise the number by
Source:
Returns:
out
Type
bigrat

(static) reciprocal()

Alias for bigrat.invert
Source:

(static) round()

Alias for bigrat.toInteger
Source:

(static) scalar_divide(out, a, b) → {bigrat}

Multiplies a bigrat's denominator by an integer
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the number to divide
b Integer amount to divide by
Source:
Returns:
out
Type
bigrat

(static) scalar_multiply(out, a, b) → {bigrat}

Multiplies a bigrat's numerator by an integer
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the number to multiply
b Integer amount to multiply the number by
Source:
Returns:
out
Type
bigrat

(static) set(out, n, d) → {bigrat}

Set the components of a bigrat to the given values
Parameters:
Name Type Description
out bigrat the receiving number
n BigInteger Numerator
d BigInteger Denominator
Source:
Returns:
out
Type
bigrat

(static) sin(out, a) → {bigrat}

Parametric sine: 2a / (1 + a²)
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number for which to calculate the parametric sine
Source:
Returns:
out
Type
bigrat

(static) sqrt(out, a) → {bigrat}

Find a bigrational number which approximates the input number when multiplied by itself
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the number to find the root of
Source:
Returns:
out
Type
bigrat

(static) str(a) → {String}

Returns a string representation
Parameters:
Name Type Description
a bigrat number to represent as a string
Source:
Returns:
string representation of the number
Type
String

(static) sub()

Alias for bigrat.subtract
Source:

(static) subtract(out, a, b) → {bigrat}

Subtracts two bigrats
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat the first operand
b bigrat the second operand
Source:
Returns:
out
Type
bigrat

(static) tan(out, a) → {bigrat}

Parametric tangent: sin(a) / cos(a)
Parameters:
Name Type Description
out bigrat the receiving number
a bigrat number for which to calculate the parametric tangent
Source:
Returns:
out
Type
bigrat

(static) toBabylonian(a) → {String}

Returns a Babylonian representation (base 60) The returned string can be evaluated in "calc - arbitrary precision calculator"
Parameters:
Name Type Description
a bigrat number to represent as a Babylonian fraction
Source:
Returns:
string containing the decimal representations of the base 60 digits and their powers, in "calc" format
Type
String

(static) toBigInteger(a) → {BigInteger}

Returns a big integer approximation (truncated towards zero)
Parameters:
Name Type Description
a bigrat number to round
Source:
Returns:
big integer approximation of the number
Type
BigInteger

(static) toContinuedFraction(a, maximum) → {Array}

Returns an array of integers representing the continued fraction
Parameters:
Name Type Description
a bigrat number to convert to a continued fraction
maximum Integer number of iterations
Source:
Returns:
integers of the continued fraction
Type
Array

(static) toDecimal(a) → {Float}

Returns a decimal approximation
Parameters:
Name Type Description
a bigrat number to approximate as a decimal
Source:
Returns:
decimal approximation of the number
Type
Float

(static) toEgyptian(a) → {String}

Returns an Egyptian representation The returned string can be evaluated in "calc - arbitrary precision calculator"
Parameters:
Name Type Description
a bigrat number to represent as an Egyptian fraction
Source:
Returns:
string representing the most simple sum of fractions having a numerator of one, in "calc" format
Type
String

(static) toInteger(a) → {Integer}

Returns a big integer approximation (truncated towards zero)
Parameters:
Name Type Description
a bigrat number to round
Source:
Returns:
native integer approximation of the number
Type
Integer

(static) toRat(out, a) → {rat}

Returns a rat from a bigrat
Parameters:
Name Type Description
out rat the receiving number
a bigrat number to truncate
Source:
Returns:
out
Type
rat

(static) traceSternBrocot(a) → {String}

Returns a string of L's and R's representing the Stern Brocot path
Parameters:
Name Type Description
a bigrat number to trace in the Stern Brocot tree
Source:
Returns:
Stern Brocot path
Type
String