Optional
value: DecimalSourceStatic
Readonly
dRepresents positive infinity.
Static
Readonly
dRepresents the largest finite value a Decimal can represent. Approximately 10^^(1.79 * 10^308).
Static
Readonly
dRepresents the smallest non-zero value a Decimal can represent. Approximately 1 / (10^^(1.79 * 10^308)).
Static
Readonly
dRepresents the largest Decimal where adding 1 to the layer is a safe operation (Decimals larger than this are too big for pow/exp/log to affect, but tetrate/iteratedlog/slog can still affect them). Approximately 10^^(9.007 * 10^15).
Static
Readonly
dRepresents the smallest Decimal where adding 1 to the layer is a safe operation. Approximately 1 / (10^^(9.007 * 10^15)).
Static
Readonly
dRepresents a NaN (Not A Number) value.
Static
Readonly
dRepresents negative infinity.
Static
Readonly
dRepresents the number -1.
Static
Readonly
dRepresents the largest value a JavaScript number can have, which is approximately 1.79 * 10^308.
Static
Readonly
dRepresents the smallest value a JavaScript number can have, which is approximately 5 * 10^-324.
Static
Readonly
dRepresents the number 1.
Static
Readonly
dRepresents the number 10.
Static
Readonly
dRepresents the number 2.
Static
Readonly
dRepresents the number 0.
Static
formatsAlphabet format
Format the value into alphabet format (a, b, c, ..., z, aa, ab, ac, ... aaa, aab, ... aaaa, ... aaaaaaaaaaaaaaa, ... aaaaaaaaaaaaaaa(2), aaaaaaaaaaaaaaa(3), ...) Basically base 26 for the exponential part / 3 Work in progress
The value to format
The accuracy
The maximum value before switching to an abbreviation
The type of format to use
The starting value. Defaults to 1e15, or 1 quadrillion.
Whether to start at aa instead of a. Defaults to false.
Optional
abbStart: numberThe starting value for abbreviations. Defaults to 9.
Get the abbreviation for a number
The value to get the abbreviation for
The starting value
Whether to start at aa instead of a
The starting value for abbreviations
The list of elements
Engineering format
Format the value into engineering format
The value to format
The accuracy
Format the value into eV (includes metric prefixes)
The value to format
Whether to include /c^2
The formatted value
Use metric instead
Exponential multiplier
The value to exponentiate
The exponent
The base
Format the value into a specific format type
The value to format
The desired accuracy (number of significant figures), defaults to 2
.
The maximum number of decimal places to display, defaults to 9
.
The type of format to use (default "mixed_sc")
Format the gain
The amount
The gain
The type
Optional
acc: numberThe accuracy
Optional
max: numberThe maximum value
Format the multiplier
The value to format
The accuracy
Format the percent
The value to format
Format the reduction
The value to format
Format the value into standard (letter abbv) format
Use format instead (with the type "st")
Format the time
The value to format (in seconds)
The accuracy
The type
Format the time long
The value to format (in seconds)
Whether to include milliseconds
The accuracy
The maximum value
The type
Infinity format
Optional
acc: numberOptional
max: numberLayer format
Optional
max: numberConverts a number to a metric representation based on the specified type.
The number to convert.
The type of metric representation to return.
The metric representation of the number. If the number is greater than the highest metric value, the function returns the highest metric abbreviation.
Mixed scientific format
Format the value into mixed scientific format (standard or scientific depending on the value)
The value to format
Optional
acc: numberThe accuracy
The maximum value
Old scientific format
Format the value into old scientific format
The value to format
The accuracy
Omega format
Format the value into omega format
The value to format
Short omega format
Format the value into short omega format
The value to format
Standard (letter abbv) format
Convert a number to a subscript
The value to convert
Convert a number to a superscript
The value to convert
Addition: returns the sum of 'this' and 'value'.
Joke function from Realm Grinder
A combination of minimum and maximum: the value returned by clamp is normally 'this', but it won't go below 'min' and it won't go above 'max'. Therefore, if 'this' < 'min', then 'min' is returned, and if 'this' > 'max', then 'max' is returned.
Returns 'this', unless 'this' is greater than 'max', in which case 'max' is returned.
Returns 'this', unless 'this' is less than 'min', in which case 'min' is returned.
Returns 1 if 'this' > 'value', returns -1 if 'this' < 'value', returns 0 if 'this' == 'value'.
Returns 1 if 'this' is greater than 'value', returns -1 if 'this' is less than 'value', returns 0 if 'this' is equal to 'value'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Compares the absolute values of this and value. Returns 1 if |'this'| > |'value'|, returns -1 if |'this'| < |'value'|, returns 0 if |'this'| == |'value'|.
Returns 1 if 'this' > 'value', returns -1 if 'this' < 'value', returns 0 if 'this' == 'value'.
Returns 1 if 'this' is greater than 'value', returns -1 if 'this' is less than 'value', returns 0 if 'this' is equal to 'value'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Division: returns the quotient of 'this' and 'value'.
Division: returns the quotient of 'this' and 'value'.
Division: returns the quotient of 'this' and 'value'.
Division: returns the quotient of 'this' and 'value'.
The Decimal equivalent of ==. Returns true if 'this' and 'value' have equal values.
Tests whether two Decimals are approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Returns true if 'this' and 'value' have equal values.
Tests whether two Decimals are approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Formats the Decimal instance with a specified accuracy and maximum decimal places.
Optional
acc: number = 2The desired accuracy (number of significant figures), defaults to 2
.
Optional
max: number = 9The maximum number of decimal places to display, defaults to 9
.
Optional
type: FormatType = "mixed_sc"The type of format, defaults to "mixed_sc"
.
A string representing the formatted Decimal value.
Formats the gain rate using the Decimal instance.
The gain value to compare
Optional
type: FormatType = "mixed_sc"The type of format (default mixed scientific)
Optional
acc: numberThe desired accuracy (number of significant figures).
Optional
max: numberThe maximum number of decimal places to display.
A string representing the formatted gain
Formats the Decimal instance in standard leter notation with a specified accuracy and maximum decimal places.
Optional
acc: number = 2The desired accuracy (number of significant figures).
Optional
max: number = 9The maximum number of decimal places to display.
Optional
type: FormatType = "st"The type of format (default standard)
A string representing the formatted Decimal value.
Turns the given components into a Decimal, but not necessarily a valid one (it's only valid if the components would already create a valid Decimal without normalization). Users of this library should not use this function.
Note: this function mutates the Decimal it is called on.
Turns the Decimal that this function is called on into a deep copy of the provided value.
Note: this function mutates the Decimal it is called on.
Turns the mantissa and exponent into a Decimal, but not necessarily a valid one. Users of this library should not use this function.
Note: this function mutates the Decimal it is called on.
Converts a string into a Decimal.
If linearhyper4 is true, then strings like "10^^8.5" will use the linear approximation of tetration even for bases <= 10.
Note: this function mutates the Decimal it is called on.
The function used by new Decimal() to create a new Decimal. Accepts a DecimalSource: uses fromNumber if given a number, uses fromString if given a string, and uses fromDecimal if given a Decimal.
Note: this function mutates the Decimal it is called on.
The gamma function extends the idea of factorials to non-whole numbers using some calculus. Gamma(x) is defined as the integral of t^(x-1) * e^-t dt from t = 0 to t = infinity, and gamma(x) = (x - 1)! for nonnegative integer x, so the factorial for non-whole numbers is defined using the gamma function.
The Decimal equivalent of >. Returns true if 'this' is greater than 'value'.
Returns true if 'this' is greater than 'value'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
The Decimal equivalent of >=. Returns true if 'this' is greater than or equal to 'value'.
Returns true if 'this' is greater than or equal to 'value'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Iterated exponentiation, the result of exping 'payload' to base 'this' 'height' times. https://andydude.github.io/tetration/archives/tetration2/ident.html
Works with negative and positive real heights. Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Identical to tetrate.
iterated log/repeated log: The result of applying log(base) 'times' times in a row. Approximately equal to subtracting 'times' from the number's slog representation. Equivalent to tetrating to a negative height.
Works with negative and positive real heights. Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
The Lambert W function, also called the omega function or product logarithm, is the solution W(x) === x*e^x. https://en.wikipedia.org/wiki/Lambert_W_function
This is a multi-valued function in the complex plane, but only two branches matter for real numbers: the "principal branch" W0, and the "non-principal branch" W_-1. W_0 works for any number >= -1/e, but W_-1 only works for nonpositive numbers >= -1/e. The "principal" parameter, which is true by default, decides which branch we're looking for: W_0 is used if principal is true, W_-1 is used if principal is false.
layeradd: like adding 'diff' to the number's slog(base) representation. Very similar to tetrate base 'base' and iterated log base 'base'.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Adds/removes layers from a Decimal, even fractional layers (e.g. its slog10 representation). Very similar to tetrate base 10 and iterated log base 10.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Penta-root, one of pentation's inverses - what number, pentated to height 'degree', equals 'this'?
Only works with the linear approximation of tetration, as starting with analytic and then switching to linear would result in inconsistent behavior for super-roots.
Super-root, one of tetration's inverses - what number, tetrated to height 'degree', equals 'this'? https://en.wikipedia.org/wiki/Tetration#Super-root
Only works with the linear approximation of tetration, as starting with analytic and then switching to linear would result in inconsistent behavior for super-roots. This only matters for non-integer degrees.
Logarithms are one of the inverses of exponentiation: this function finds the Decimal X such that base^X = 'this'.
Logarithms are one of the inverses of exponentiation: this function finds the Decimal X such that base^X = 'this'.
The Decimal equivalent of <. Returns true if 'this' is less than 'value'.
Returns true if 'this' is less than 'value'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
The Decimal equivalent of <=. Returns true if 'this' is less than or equal to 'value'.
Returns true if 'this' is less than or equal to 'value'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Returns whichever of 'this' and 'value' is higher.
Returns whichever of 'this' and 'value' has a larger absolute value.
Returns whichever of 'this' and 'value' is lower.
Returns whichever of 'this' and 'value' has a smaller absolute value.
Subtraction: returns the difference between 'this' and 'value'.
Returns the remainder of 'this' divided by 'value': for example, 5 mod 2 = 1, because the remainder of 5 / 2 is 1. Uses the "truncated division" modulo, which is the same as JavaScript's native modulo operator (%)... unless 'floored' is true, in which case it uses the "floored" modulo, which is closer to how modulo works in number theory. These two forms of modulo are the same when only positive numbers are involved, but differ in how they work with negative numbers.
Returns the remainder of 'this' divided by 'value': for example, 5 mod 2 = 1, because the remainder of 5 / 2 is 1. Uses the "truncated division" modulo, which is the same as JavaScript's native modulo operator (%)... unless 'floored' is true, in which case it uses the "floored" modulo, which is closer to how modulo works in number theory. These two forms of modulo are the same when only positive numbers are involved, but differ in how they work with negative numbers.
Returns the remainder of 'this' divided by 'value': for example, 5 mod 2 = 1, because the remainder of 5 / 2 is 1. Uses the "truncated division" modulo, which is the same as JavaScript's native modulo operator (%)... unless 'floored' is true, in which case it uses the "floored" modulo, which is closer to how modulo works in number theory. These two forms of modulo are the same when only positive numbers are involved, but differ in how they work with negative numbers.
Multiplication: returns the product of 'this' and 'value'.
Multiplication: returns the product of 'this' and 'value'.
The Decimal equivalent of !=. Returns true if 'this' and 'value' do not have equal values.
Tests whether two Decimals are not approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Returns true if 'this' and 'value' do not have equal values.
Tests whether two Decimals are not approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Penta-logarithm, one of pentation's inverses, tells you what height you'd have to pentate 'base' to to get 'this'.
Grows incredibly slowly. For bases above 2, you won't be seeing a result greater than 5 out of this function.
Accepts a number of iterations (default is 100), and use binary search to, after making an initial guess, hone in on the true value, assuming pentation as the ground truth.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
For non-whole pentation heights, the linear approximation of pentation is always used, as there is no defined analytic approximation of pentation.
Pentation/pentate: The result of tetrating 'height' times in a row. An absurdly strong operator - Decimal.pentate(2, 4.28) and Decimal.pentate(10, 2.37) are already too huge for break_eternity.js! https://en.wikipedia.org/wiki/Pentation
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
For non-whole pentation heights, the linear approximation of pentation is always used, as there is no defined analytic approximation of pentation.
Addition: returns the sum of 'this' and 'value'.
Exponentiation: Returns the result of 'this' ^ 'value' (often written as 'this' ** 'value' in programming languages).
Exponentiation: Returns the result of 'value' ^ 'this' (often written as 'value' ** 'this' in programming languages).
Roots are one of the inverses of exponentiation: this function finds the Decimal X such that X ^ 'value' = 'this'. Equivalent to 'this' ^ (1 / 'value'), which is written here as this.pow(value.recip()).
Scales a currency value using a specified scaling function.
The value at which scaling starts.
The scaling factor.
The scaling mode. Use "pow" for power scaling or "exp" for exponential scaling.
Optional
rev: boolean = falseWhether to reverse the scaling operation (unscaling).
Super-logarithm, one of tetration's inverses, tells you what size power tower you'd have to tetrate 'base' to to get 'this'. https://en.wikipedia.org/wiki/Super-logarithm
By definition, will never be higher than 1.8e308 in break_eternity.js, since a power tower 1.8e308 numbers tall is the largest representable number.
Accepts a number of iterations (default is 100), and use binary search to, after making an initial guess, hone in on the true value, assuming tetration as the ground truth.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Applies a soft cap to a DecimalClone value using a specified soft cap function.
The value at which the soft cap starts.
The power or factor used in the soft cap calculation.
The soft cap mode. Use "pow" for power soft cap, "mul" for multiplication soft cap, or "exp" for exponential soft cap.
The super square-root function - what number, tetrated to height 2, equals 'this'? https://en.wikipedia.org/wiki/Tetration#Super-root
Subtraction: returns the difference between 'this' and 'value'.
Subtraction: returns the difference between 'this' and 'value'.
Tetration: The result of exponentiating 'this' to 'this' 'height' times in a row. https://en.wikipedia.org/wiki/Tetration
If payload != 1, then this is 'iterated exponentiation', the result of exping 'payload' to base 'this' 'height' times. https://andydude.github.io/tetration/archives/tetration2/ident.html
Works with negative and positive real heights. Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Multiplication: returns the product of 'this' and 'value'.
Converts the Decimal instance to a Roman numeral representation.
Optional
max: DecimalSource = 5000Max before it returns the original
A string representing the Roman numeral equivalent of the Decimal value, or the original Decimal instance if it is greater than or equal to 5000 or less than 1.
Returns a string representation of the Decimal it's called on. This string is written as a plain number for most layer 0 numbers, in scientific notation for layer 1 numbers (and layer 0 numbers below 1e-6), in "ee...X" form for numbers from layers 2 to 5, and in (e^N)X form for layer > 5.
Static
absAbsolute value function: returns 'value' if 'value' >= 0, returns the negative of 'value' if 'value' < 0.
Static
absReturns the base-10 logarithm of abs('value').
Static
acosThe arccosine function, the inverse of the cosine function.
Static
acoshHyperbolic arccosine, the inverse of hyperbolic cosine.
Static
addAddition: returns the sum of the two Decimals.
Static
affordIf you're willing to spend 'resourcesAvailable' and want to buy something with additively increasing cost each purchase (start at priceStart, add by priceAdd, already own currentOwned), how much of it can you buy?
Static
affordStatic
affordIf you're willing to spend 'resourcesAvailable' and want to buy something with exponentially increasing cost each purchase (start at priceStart, multiply by priceRatio, already own currentOwned), how much of it can you buy? Adapted from Trimps source code.
Static
affordStatic
asinThe arcsine function, the inverse of the sine function.
Static
asinhHyperbolic arcsine, the inverse of hyperbolic sine.
Static
atanThe arctangent function, the inverse of the tangent function.
Static
atanhHyperbolic arcctangent, the inverse of hyperbolic tangent.
Static
cbrtCube root: finds the Decimal X such that X^3 equals 'value'. Equivalent to X^(1/3).
Static
ceil"Rounds" the value to the nearest integer that's greater than or equal to it.
Static
clampA combination of minimum and maximum: the value returned by clamp is normally 'value', but it won't go below 'min' and it won't go above 'max'. Therefore, if 'value' < 'min', then 'min' is returned, and if 'value' > 'max', then 'max' is returned.
Static
clampReturns 'value', unless 'value' is greater than 'max', in which case 'max' is returned.
Static
clampReturns 'value', unless 'value' is less than 'min', in which case 'min' is returned.
Static
cloneStatic
cmpReturns 1 if 'value' > 'other', returns -1 if 'value' < 'other', returns 0 if 'value' == 'other'.
Static
cmp_Returns 1 if 'value' is greater than 'other', returns -1 if 'value' is less than 'other', returns 0 if 'value' is equal to 'other'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
cmpabsCompares the absolute values of this and value. Returns 1 if |'value'| > |'other'|, returns -1 if |'value'| < |'other'|, returns 0 if |'value'| == |'other'|.
Static
compareReturns 1 if 'value' > 'other', returns -1 if 'value' < 'other', returns 0 if 'value' == 'other'.
Static
compare_Returns 1 if 'value' is greater than 'other', returns -1 if 'value' is less than 'other', returns 0 if 'value' is equal to 'other'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
cosThe cosine function, one of the main two trigonometric functions. Behaves periodically with period 2*pi.
Static
coshHyperbolic cosine: cosh(x) = (e^x + e^-x)/2.
Static
critical_Static
cubeCubing a number means raising it to the third power.
Static
divDivision: returns the quotient of 'value' and 'other'.
Static
divideDivision: returns the quotient of 'value' and 'other'.
Static
efficiencyWhen comparing two purchases that cost (resource) and increase your resource/sec by (deltaRpS), the lowest efficiency score is the better one to purchase. From Frozen Cookies: http://cookieclicker.wikia.com/wiki/Frozen_Cookies_(JavaScript_Add-on)#Efficiency.3F_What.27s_that.3F
Static
efficiencyStatic
eqThe Decimal equivalent of ==. Returns true if 'value' and 'other' have equal values.
Static
eq_Tests whether two Decimals are approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
equalsReturns true if 'value' and 'other' have equal values.
Static
equals_Tests whether two Decimals are approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
expBase-e exponentiation: returns e^'value'.
Static
factorialFor positive integers, X factorial (written as X!) equals X * (X - 1) * (X - 2) *... * 3 * 2 * 1. 0! equals 1. This can be extended to real numbers (except for negative integers) via the gamma function, which is what this function does.
Optional
_other: undefinedStatic
floor"Rounds" the value to the nearest integer that's less than or equal to it.
Static
formatFormats the Decimal instance with a specified accuracy and maximum decimal places.
The Decimal instance to format.
Optional
acc: number = 2The desired accuracy (number of significant figures), defaults to 2
.
Optional
max: number = 9The maximum number of decimal places to display, defaults to 9
.
Optional
type: FormatType = "mixed_sc"The type of format, defaults to "mixed_sc"
.
A string representing the formatted Decimal value.
Static
formatOptional
acc: numberOptional
max: numberStatic
formatSTStatic
fromStatic
fromTurns the given components into a Decimal, but not necessarily a valid one (it's only valid if the components would already create a valid Decimal without normalization). Users of this library should not use this function.
Static
fromStatic
fromStatic
fromStatic
fromStatic
fromStatic
fromThe function used by new Decimal() to create a new Decimal. Accepts a DecimalSource: uses fromNumber if given a number, uses fromString if given a string, and uses fromDecimal if given a Decimal.
Static
fromConverts a DecimalSource to a Decimal, without constructing a new Decimal if the provided value is already a Decimal.
As the return value could be the provided value itself, this function
returns a read-only Decimal to prevent accidental mutations of the value.
Use new Decimal(value)
to explicitly create a writeable copy if mutation
is required.
Static
gammaThe gamma function extends the idea of factorials to non-whole numbers using some calculus. Gamma(x) is defined as the integral of t^(x-1) * e^-t dt from t = 0 to t = infinity, and gamma(x) = (x - 1)! for nonnegative integer x, so the factorial for non-whole numbers is defined using the gamma function.
Optional
_other: undefinedStatic
gtThe Decimal equivalent of >. Returns true if 'value' is greater than 'other'.
Static
gt_Returns true if 'value' is greater than 'other'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
gteThe Decimal equivalent of >=. Returns true if 'value' is greater than or equal to 'other'.
Static
gte_Returns true if 'value' is greater than or equal to 'other'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
increasingThis function takes a Decimal => Decimal function as its argument (or DecimalSource => Decimal, that's fine too), and it returns a DecimalSource => Decimal function that's an inverse of the first one, which uses binary search to find its target. The resulting function will call the original many times, so it may be noticably slower than the original.
This function is only intended to be used on continuous, strictly increasing (or, using the decreasing parameter, strictly decreasing) functions. Its resulting function may output erroneous results if the original function was not strictly increasing. If the function is increasing but not strictly increasing, the inverse will, in ranges where the original function is constant, try to return the value closest to 0 out of the multiple correct values. If the function is not continuous, the inverse should return the correct answer in cases where the given value is returned by some input to the original function, but it will return an erroneous result otherwise (the correct result would be to return NaN, but checking to ensure continuity is not implemented)
The Decimal => Decimal function to create an inverse function of.
This parameter is false by default. If this parameter is true, the original function should be strictly decreasing instead of strictly increasing.
The amount of iterations that the inverse function runs before it gives up and returns whatever value it's found thus far. Default is 120, which should be enough to always be as precise as floating point allows.
The original function is assumed to have this value as the lowest value in its domain. Is Decimal.dLayerMax.neg() by default, which means all negative finite values are allowed but infinity is not.
The original function is assumed to have this value as the highest value in its domain. Is Decimal.dLayerMax by default, which means all positive finite values are allowed but infinity is not.
If the input to the inverse function is below this value, the inverse function assumes the input is not in the range and returns NaN. Is Decimal.dLayerMax.neg() by default, which means all negative finite values are allowed but infinity is not.
If the input to the inverse function is above this value, the inverse function assumes the input is not in the range and returns NaN. Is Decimal.dLayerMax by default, which means all positive finite values are allowed but infinity is not.
Static
isReturns true if the given value is finite (by Decimal standards, not by floating point standards - a humongous Decimal like 10^^10^100 is still finite!)
Static
isReturns true if the given value is an NaN value.
Static
iteratedexpIterated exponentiation, the result of exping 'payload' to base 'value' 'height' times. https://andydude.github.io/tetration/archives/tetration2/ident.html
Works with negative and positive real heights. Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Identical to tetrate.
Static
iteratedlogiterated log/repeated log: The result of applying log(base) 'times' times in a row. Approximately equal to subtracting 'times' from the number's slog representation. Equivalent to tetrating to a negative height.
Works with negative and positive real heights. Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Static
lambertwThe Lambert W function, also called the omega function or product logarithm, is the solution W(x) === x*e^x. https://en.wikipedia.org/wiki/Lambert_W_function
This is a multi-valued function in the complex plane, but only two branches matter for real numbers: the "principal branch" W0, and the "non-principal branch" W_-1. W_0 works for any number >= -1/e, but W_-1 only works for negative numbers >= -1/e. The "principal" parameter, which is true by default, decides which branch we're looking for: W_0 is used if principal is true, W_-1 is used if principal is false.
Static
layeraddlayeradd: like adding 'diff' to the number's slog(base) representation. Very similar to tetrate base 'base' and iterated log base 'base'.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Static
layeradd10Adds/removes layers from a Decimal, even fractional layers (e.g. its slog10 representation). Very similar to tetrate base 10 and iterated log base 10.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Static
linear_Penta-root, one of pentation's inverses - what number, pentated to height 'degree', equals 'value'?
Only works with the linear approximation of tetration, as starting with analytic and then switching to linear would result in inconsistent behavior for super-roots.
Static
linear_Super-root, one of tetration's inverses - what number, tetrated to height 'degree', equals 'value'? https://en.wikipedia.org/wiki/Tetration#Super-root
Only works with the linear approximation of tetration, as starting with analytic and then switching to linear would result in inconsistent behavior for super-roots. This only matters for non-integer degrees.
Static
lnBase-e logarithm, also known as the "natural" logarithm: returns the Decimal X such that e^X = 'value'.
Static
lngammaReturns the natural (base-e) logarithm of Gamma('value').
Optional
_other: undefinedStatic
logLogarithms are one of the inverses of exponentiation: this function finds the Decimal X such that base^X = 'value'.
Static
log10Base-10 logarithm: returns the Decimal X such that 10^X = 'value'. For numbers above layer 0, this is equivalent to subtracting 1 from layer and normalizing.
Static
log2Base-2 logarithm: returns the Decimal X such that 2^X = 'value'.
Static
logarithmLogarithms are one of the inverses of exponentiation: this function finds the Decimal X such that base^X = 'value'.
Static
ltThe Decimal equivalent of <. Returns true if 'value' is less than 'other'.
Static
lt_Returns true if 'value' is less than 'other'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
lteThe Decimal equivalent of <=. Returns true if 'value' is less than or equal to 'other'.
Static
lte_Returns true if 'value' is less than or equal to 'other'. However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
maxReturns whichever of 'value' and 'other' is higher.
Static
maxabsReturns whichever of 'value' and 'other' has a smaller absolute value.
Static
minReturns whichever of 'value' and 'other' is lower.
Static
minabsReturns whichever of 'value' and 'other' has a larger absolute value.
Static
minusSubtraction: returns the difference between 'value' and 'other'.
Static
modReturns the remainder of 'this' divided by 'value': for example, 5 mod 2 = 1, because the remainder of 5 / 2 is 1. Uses the "truncated division" modulo, which is the same as JavaScript's native modulo operator (%)... unless 'floored' is true, in which case it uses the "floored" modulo, which is closer to how modulo works in number theory. These two forms of modulo are the same when only positive numbers are involved, but differ in how they work with negative numbers.
Static
modularReturns the remainder of 'this' divided by 'value': for example, 5 mod 2 = 1, because the remainder of 5 / 2 is 1. Uses the "truncated division" modulo, which is the same as JavaScript's native modulo operator (%)... unless 'floored' is true, in which case it uses the "floored" modulo, which is closer to how modulo works in number theory. These two forms of modulo are the same when only positive numbers are involved, but differ in how they work with negative numbers.
Static
moduloReturns the remainder of 'this' divided by 'value': for example, 5 mod 2 = 1, because the remainder of 5 / 2 is 1. Uses the "truncated division" modulo, which is the same as JavaScript's native modulo operator (%)... unless 'floored' is true, in which case it uses the "floored" modulo, which is closer to how modulo works in number theory. These two forms of modulo are the same when only positive numbers are involved, but differ in how they work with negative numbers.
Static
mulMultiplication: returns the product of the two Decimals.
Static
multiplyMultiplication: returns the product of the two Decimals.
Static
negReturns the negative of the given value.
Static
negateReturns the negative of the given value.
Static
negatedReturns the negative of the given value.
Static
neqThe Decimal equivalent of !=. Returns true if 'value' and 'other' do not have equal values.
Static
neq_Tests whether two Decimals are not approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
notReturns true if 'value' and 'other' do not have equal values.
Static
notTests whether two Decimals are not approximately equal, up to a certain tolerance. Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. For example, if you put in 1e-9, then any number closer to the larger number than (larger number)*1e-9 will be considered equal.
Static
penta_Penta-logarithm, one of pentation's inverses, tells you what height you'd have to pentate 'base' to to get 'value'.
Grows incredibly slowly. For bases above 2, you won't be seeing a result greater than 5 out of this function.
Accepts a number of iterations (default is 100), and use binary search to, after making an initial guess, hone in on the true value, assuming pentation as the ground truth.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
For non-whole pentation heights, the linear approximation of pentation is always used, as there is no defined analytic approximation of pentation.
Static
pentatePentation/pentate: The result of tetrating 'height' times in a row. An absurdly strong operator - Decimal.pentate(2, 4.28) and Decimal.pentate(10, 2.37) are already too huge for break_eternity.js! https://en.wikipedia.org/wiki/Pentation
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
For non-whole pentation heights, the linear approximation of pentation is always used, as there is no defined analytic approximation of pentation.
Static
p"Positive log10": Returns the base-10 logarithm of nonnegative Decimals, but returns 0 for negative Decimals.
Static
plusAddition: returns the sum of the two Decimals.
Static
powExponentiation: Returns the result of 'value' ^ 'other' (often written as 'value' ** 'other' in programming languages).
Static
pow10Raises 10 to the power of 'value', i.e. (10^'value'). For positive numbers above 1, this is equivalent to adding 1 to the value's layer and normalizing.
Static
randomReturns a random Decimal value between the specified minimum and maximum values. This suffers from floating point errors if you want to generate a random number close to either the minimum or the maximum.
Optional
min: DecimalSource = 0The minimum value, defaults to 0
.
Optional
max: DecimalSource = 1The maximum value, defaults to 1
.
A random Decimal value between the minimum and maximum values.
Static
randomStatic
randomReturns a random boolean value based on the specified probability.
The probability of returning true
. Must be between 0
and 1
.
A boolean value based on the probability.
Static
recipReturns the reciprocal (1 / X) of the given value.
Static
reciprocalReturns the reciprocal (1 / X) of the given value.
Static
reciprocateReturns the reciprocal (1 / X) of the given value.
Static
rootRoots are one of the inverses of exponentiation: this function finds the Decimal X such that X ^ 'other' = 'value'. Equivalent to 'value' ^ (1 / 'other'), which is written here as value.pow(other.recip()).
Static
roundRounds the value to the nearest integer.
Static
scaleStatic
sgnReturns the sign of the given value.
Static
signReturns the sign of the given value.
Static
sinThe sine function, one of the main two trigonometric functions. Behaves periodically with period 2*pi.
Static
sinhHyperbolic sine: sinh(X) = (e^x - e^-x)/2.
Static
slogSuper-logarithm, one of tetration's inverses, tells you what size power tower you'd have to tetrate 'base' to to get 'value'. https://en.wikipedia.org/wiki/Super-logarithm
By definition, will never be higher than 1.8e308 in break_eternity.js, since a power tower 1.8e308 numbers tall is the largest representable number.
Accepts a number of iterations (default is 100), and use binary search to, after making an initial guess, hone in on the true value, assuming tetration as the ground truth.
Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Static
slog_Static
smoothSmoothly interpolates between the current value and the target value over time using a smoothing factor and deltaTime.
The current value to interpolate from.
The target value to interpolate towards.
The smoothing factor controlling the interpolation speed. A higher value results in slower interpolation.
The time elapsed since the last frame in seconds.
current
and target
.Static
softcapStatic
sqrSquaring a number means multiplying it by itself, a.k.a. raising it to the second power.
Static
sqrtSquare root: finds the Decimal X such that X * X, a.k.a X^2, equals 'value'. Equivalent to X^(1/2).
Static
ssqrtThe super square-root function - what number, tetrated to height 2, equals 'value'? https://en.wikipedia.org/wiki/Tetration#Super-root
Static
subSubtraction: returns the difference between 'value' and 'other'.
Static
subtractSubtraction: returns the difference between 'value' and 'other'.
Static
sumHow much resource would it cost to buy (numItems) items if you already have currentOwned, the initial price is priceStart and it adds priceAdd each purchase? Adapted from http://www.mathwords.com/a/arithmetic_series.htm
Static
sumStatic
sumHow much resource would it cost to buy (numItems) items if you already have currentOwned, the initial price is priceStart and it multiplies by priceRatio each purchase?
Static
sumStatic
tanThe tangent function, equal to sine divided by cosine. Behaves periodically with period pi.
Static
tanhHyperbolic tangent: tanh(x) = sinh(x)/cosh(x).
Static
tetrateTetration: The result of exponentiating 'value' to 'value' 'height' times in a row. https://en.wikipedia.org/wiki/Tetration
If payload != 1, then this is 'iterated exponentiation', the result of exping 'payload' to base 'value' 'height' times. https://andydude.github.io/tetration/archives/tetration2/ident.html
Works with negative and positive real heights. Tetration for non-integer heights does not have a single agreed-upon definition, so this library uses an analytic approximation for bases <= 10, but it reverts to the linear approximation for bases > 10. If you want to use the linear approximation even for bases <= 10, set the linear parameter to true. Analytic approximation is not currently supported for bases > 10.
Static
tetrate_Static
timesMultiplication: returns the product of the two Decimals.
Static
toStatic
truncExtracts the integer part of the Decimal and returns it. Behaves like floor on positive numbers, but behaves like ceiling on negative numbers.
The value of the Decimal is sign * 10^10^10...^mag, with (layer) 10s. If the layer is not 0, then negative mag means it's the reciprocal of the corresponding number with positive mag.