Optionalvalue: DecimalSourceStatic ReadonlydRepresents positive infinity.
Static ReadonlydRepresents the largest finite value a Decimal can represent. Approximately 10^^(1.79 * 10^308).
Static ReadonlydRepresents the smallest non-zero value a Decimal can represent. Approximately 1 / (10^^(1.79 * 10^308)).
Static ReadonlydRepresents 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 ReadonlydRepresents the smallest Decimal where adding 1 to the layer is a safe operation. Approximately 1 / (10^^(9.007 * 10^15)).
Static ReadonlydRepresents a NaN (Not A Number) value.
Static ReadonlydRepresents negative infinity.
Static ReadonlydRepresents the number -1.
Static ReadonlydRepresents the largest value a JavaScript number can have, which is approximately 1.79 * 10^308.
Static ReadonlydRepresents the smallest value a JavaScript number can have, which is approximately 5 * 10^-324.
Static ReadonlydRepresents the number 1.
Static ReadonlydRepresents the number 10.
Static ReadonlydRepresents the number 2.
Static ReadonlydRepresents the number 0.
StaticformatsAlphabet 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.
OptionalabbStart: 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
Optionalacc: numberThe accuracy
Optionalmax: 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
Optionalacc: numberOptionalmax: numberLayer format
Optionalmax: 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
Optionalacc: 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.
Optionalacc: number = 2The desired accuracy (number of significant figures), defaults to 2.
Optionalmax: number = 9The maximum number of decimal places to display, defaults to 9.
Optionaltype: 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
Optionaltype: FormatType = "mixed_sc"The type of format (default mixed scientific)
Optionalacc: numberThe desired accuracy (number of significant figures).
Optionalmax: 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.
Optionalacc: number = 2The desired accuracy (number of significant figures).
Optionalmax: number = 9The maximum number of decimal places to display.
Optionaltype: 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.
Optionalrev: 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.
Optionalmax: 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.
StaticabsAbsolute value function: returns 'value' if 'value' >= 0, returns the negative of 'value' if 'value' < 0.
StaticabsReturns the base-10 logarithm of abs('value').
StaticacosThe arccosine function, the inverse of the cosine function.
StaticacoshHyperbolic arccosine, the inverse of hyperbolic cosine.
StaticaddAddition: returns the sum of the two Decimals.
StaticaffordIf 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?
StaticaffordStaticaffordIf 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.
StaticaffordStaticasinThe arcsine function, the inverse of the sine function.
StaticasinhHyperbolic arcsine, the inverse of hyperbolic sine.
StaticatanThe arctangent function, the inverse of the tangent function.
StaticatanhHyperbolic arcctangent, the inverse of hyperbolic tangent.
StaticcbrtCube root: finds the Decimal X such that X^3 equals 'value'. Equivalent to X^(1/3).
Staticceil"Rounds" the value to the nearest integer that's greater than or equal to it.
StaticclampA 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.
StaticclampReturns 'value', unless 'value' is greater than 'max', in which case 'max' is returned.
StaticclampReturns 'value', unless 'value' is less than 'min', in which case 'min' is returned.
StaticcloneStaticcmpReturns 1 if 'value' > 'other', returns -1 if 'value' < 'other', returns 0 if 'value' == 'other'.
Staticcmp_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.
StaticcmpabsCompares the absolute values of this and value. Returns 1 if |'value'| > |'other'|, returns -1 if |'value'| < |'other'|, returns 0 if |'value'| == |'other'|.
StaticcompareReturns 1 if 'value' > 'other', returns -1 if 'value' < 'other', returns 0 if 'value' == 'other'.
Staticcompare_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.
StaticcosThe cosine function, one of the main two trigonometric functions. Behaves periodically with period 2*pi.
StaticcoshHyperbolic cosine: cosh(x) = (e^x + e^-x)/2.
Staticcritical_StaticcubeCubing a number means raising it to the third power.
StaticdivDivision: returns the quotient of 'value' and 'other'.
StaticdivideDivision: returns the quotient of 'value' and 'other'.
StaticefficiencyWhen 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
StaticefficiencyStaticeqThe Decimal equivalent of ==. Returns true if 'value' and 'other' have equal values.
Staticeq_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.
StaticequalsReturns true if 'value' and 'other' have equal values.
Staticequals_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.
StaticexpBase-e exponentiation: returns e^'value'.
StaticfactorialFor 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: undefinedStaticfloor"Rounds" the value to the nearest integer that's less than or equal to it.
StaticformatFormats the Decimal instance with a specified accuracy and maximum decimal places.
The Decimal instance to format.
Optionalacc: number = 2The desired accuracy (number of significant figures), defaults to 2.
Optionalmax: number = 9The maximum number of decimal places to display, defaults to 9.
Optionaltype: FormatType = "mixed_sc"The type of format, defaults to "mixed_sc".
A string representing the formatted Decimal value.
StaticformatOptionalacc: numberOptionalmax: numberStaticformatSTStaticfromStaticfromTurns 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.
StaticfromStaticfromStaticfromStaticfromStaticfromStaticfromThe 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.
StaticfromConverts 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.
StaticgammaThe 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: undefinedStaticgtThe Decimal equivalent of >. Returns true if 'value' is greater than 'other'.
Staticgt_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.
StaticgteThe Decimal equivalent of >=. Returns true if 'value' is greater than or equal to 'other'.
Staticgte_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.
StaticincreasingThis 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.
StaticisReturns 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!)
StaticisReturns true if the given value is an NaN value.
StaticiteratedexpIterated 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.
Staticiteratedlogiterated 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.
StaticlambertwThe 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.
Staticlayeraddlayeradd: 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.
Staticlayeradd10Adds/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.
Staticlinear_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.
Staticlinear_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.
StaticlnBase-e logarithm, also known as the "natural" logarithm: returns the Decimal X such that e^X = 'value'.
StaticlngammaReturns the natural (base-e) logarithm of Gamma('value').
Optional_other: undefinedStaticlogLogarithms are one of the inverses of exponentiation: this function finds the Decimal X such that base^X = 'value'.
Staticlog10Base-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.
Staticlog2Base-2 logarithm: returns the Decimal X such that 2^X = 'value'.
StaticlogarithmLogarithms are one of the inverses of exponentiation: this function finds the Decimal X such that base^X = 'value'.
StaticltThe Decimal equivalent of <. Returns true if 'value' is less than 'other'.
Staticlt_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.
StaticlteThe Decimal equivalent of <=. Returns true if 'value' is less than or equal to 'other'.
Staticlte_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.
StaticmaxReturns whichever of 'value' and 'other' is higher.
StaticmaxabsReturns whichever of 'value' and 'other' has a smaller absolute value.
StaticminReturns whichever of 'value' and 'other' is lower.
StaticminabsReturns whichever of 'value' and 'other' has a larger absolute value.
StaticminusSubtraction: returns the difference between 'value' and 'other'.
StaticmodReturns 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.
StaticmodularReturns 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.
StaticmoduloReturns 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.
StaticmulMultiplication: returns the product of the two Decimals.
StaticmultiplyMultiplication: returns the product of the two Decimals.
StaticnegReturns the negative of the given value.
StaticnegateReturns the negative of the given value.
StaticnegatedReturns the negative of the given value.
StaticneqThe Decimal equivalent of !=. Returns true if 'value' and 'other' do not have equal values.
Staticneq_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.
StaticnotReturns true if 'value' and 'other' do not have equal values.
StaticnotTests 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.
Staticpenta_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.
StaticpentatePentation/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.
Staticp"Positive log10": Returns the base-10 logarithm of nonnegative Decimals, but returns 0 for negative Decimals.
StaticplusAddition: returns the sum of the two Decimals.
StaticpowExponentiation: Returns the result of 'value' ^ 'other' (often written as 'value' ** 'other' in programming languages).
Staticpow10Raises 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.
StaticrandomReturns 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.
Optionalmin: DecimalSource = 0The minimum value, defaults to 0.
Optionalmax: DecimalSource = 1The maximum value, defaults to 1.
A random Decimal value between the minimum and maximum values.
StaticrandomStaticrandomReturns 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.
StaticrecipReturns the reciprocal (1 / X) of the given value.
StaticreciprocalReturns the reciprocal (1 / X) of the given value.
StaticreciprocateReturns the reciprocal (1 / X) of the given value.
StaticrootRoots 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()).
StaticroundRounds the value to the nearest integer.
StaticscaleStaticsgnReturns the sign of the given value.
StaticsignReturns the sign of the given value.
StaticsinThe sine function, one of the main two trigonometric functions. Behaves periodically with period 2*pi.
StaticsinhHyperbolic sine: sinh(X) = (e^x - e^-x)/2.
StaticslogSuper-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.
Staticslog_StaticsmoothSmoothly 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.StaticsoftcapStaticsqrSquaring a number means multiplying it by itself, a.k.a. raising it to the second power.
StaticsqrtSquare root: finds the Decimal X such that X * X, a.k.a X^2, equals 'value'. Equivalent to X^(1/2).
StaticssqrtThe super square-root function - what number, tetrated to height 2, equals 'value'? https://en.wikipedia.org/wiki/Tetration#Super-root
StaticsubSubtraction: returns the difference between 'value' and 'other'.
StaticsubtractSubtraction: returns the difference between 'value' and 'other'.
StaticsumHow 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
StaticsumStaticsumHow 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?
StaticsumStatictanThe tangent function, equal to sine divided by cosine. Behaves periodically with period pi.
StatictanhHyperbolic tangent: tanh(x) = sinh(x)/cosh(x).
StatictetrateTetration: 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.
Statictetrate_StatictimesMultiplication: returns the product of the two Decimals.
StatictoStatictruncExtracts 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.