Private constructorStatic approxTest whether two numbers are approximately equal: closer together than some given interval of refinement.
If no interval is given, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON|Number.EPSILON is used.
a number to compare
a number to compare
the interval of refinement
are x and y within epsilon distance apart?
Static averageAverage two numbers, with a weight favoring the 2nd number.
1st finite number
2nd finite number
weight of 2nd number; between 0–1
exactly interpolateArithmetic(x, y, w)
This method is an alias of xjs_Math.interpolateArithmetic.
Static clampReturn the argument, clamped between two bounds.
This method returns the argument unchanged iff it is loosely between min and max;
it returns min iff the argument is strictly less than min;
and max iff the argument is strictly greater than max.
If min === max then this method returns that value.
If min > max then this method switches the bounds.
the lower bound
the value to clamp between the bounds
the upper bound
Math.min(Math.max(min, x), max)
Static clampxjs_Math.clamp, but for bigint types.
the lower bound
the value to clamp between the bounds
the upper bound
the clamped value
Static interpolateLinearlly interpolate between, or extrapolate from, two numbers.
If the argument p is within the interval [0, 1], the result is an interpolation within the interval [a, b],
such that p == 0 produces a and p == 1 produces b.
For example, interpolateArithmetic(10, 20, 0.7) will return 17, while
interpolateArithmetic(20, 10, 0.7) will return 13 (the same result as interpolateArithmetic(10, 20, 1 - 0.7)).
If p is outside [0, 1], the result is an extrapolation outside the range of [a, b].
For example, interpolateArithmetic(10, 20, 1.3) will return 23, and
interpolateArithmetic(10, 20, -0.3) will return 7.
p defaults to 0.5, thus yielding an even average, that is,
the arithmetic mean, of the two numbers.
1st number
2nd number
the interpolation/extrapolation parameter
exactly a * (1 - p) + (b * p)
https://www.desmos.com/calculator/tfuwejqtav
if a, b, or p is not a finite number
if an argument is NaN
Static interpolateExponentially interpolate between, or extrapolate from, two numbers.
If the argument p is within the interval [0, 1], the result is an interpolation within the interval [a, b],
such that p == 0 produces a and p == 1 produces b.
For example, interpolateGeometric(10, 20, 0.7) will return ~16.245, while
interpolateGeometric(20, 10, 0.7) will return ~12.311 (the same result as interpolateGeometric(10, 20, 1 - 0.7)).
If p is outside [0, 1], the result is an extrapolation outside the range of [a, b].
For example, interpolateGeometric(10, 20, 1.3) will return ~24.623, and
interpolateGeometric(10, 20, -0.3) will return ~8.123.
p defaults to 0.5, thus yielding an even average, that is,
the geometric mean, of the two numbers.
1st number
2nd number
the interpolation/extrapolation parameter
exactly a ** (1 - p) * b ** p
https://www.desmos.com/calculator/tfuwejqtav
if a, b, or p is not a finite number
if an argument is NaN
Static interpolateRationally interpolate between, or extrapolate from, two numbers.
If the argument p is within the interval [0, 1], the result is an interpolation within the interval [a, b],
such that p == 0 produces a and p == 1 produces b.
For example, interpolateHarmonic(10, 20, 0.7) will return ~15.385, while
interpolateHarmonic(20, 10, 0.7) will return ~11.765 (the same result as interpolateHarmonic(10, 20, 1 - 0.7)).
If p is outside [0, 1], the result is an extrapolation outside the range of [a, b].
For example, interpolateHarmonic(10, 20, 1.3) will return ~28.571, and
interpolateHarmonic(10, 20, -0.3) will return ~8.696.
p defaults to 0.5, thus yielding an even average, that is,
the harmonic mean, of the two numbers.
1st number
2nd number
the interpolation/extrapolation parameter
exactly 1 / interpolateArithmetic(1/a, 1/b, p)
https://www.desmos.com/calculator/tfuwejqtav
if a, b, or p is not a finite number
if an argument is NaN
Static isStatic maxStatic meanReturn the arithmetic mean of a set of numbers.
meanArithmetic(a,b) == (a + b) / 2
meanArithmetic(a,b,c) == (a + b + c) / 3
Rest ...nums: number[]finite numbers to average
the arithmetic mean of the given numbers
if one of the numbers is not finite
if one of the numbers is NaN
Static meanReturn the geomeric mean of a set of numbers.
meanGeometric(a,b) == (a * b) ** (1/2)
meanGeometric(a,b,c) == (a * b * c) ** (1/3)
Rest ...nums: number[]finite numbers to average
the geometric mean of the given numbers
if one of the numbers is not finite
if one of the numbers is NaN
Static meanReturn the harmonic mean of a set of numbers.
meanHarmonic(a,b) == 1 / ((1/a + 1/b) / 2)
meanHarmonic(a,b,c) == 1 / ((1/a + 1/b + 1/c) / 3)
Rest ...nums: number[]finite numbers to average
the harmonic mean of the given numbers
if one of the numbers is not finite
if one of the numbers is NaN
Static minStatic modReturn the remainder of Euclidean division of x by n.
This method returns x % n when x is positive,
but returns a positive result when x is negative.
The divisor n must be positive.
the dividend
the divisor, a positive integer
exactly ((x % n) + n) % n
if n is not a positive integer
Static tetrateReturn the nth tetration of x.
Tetration is considered the next hyperoperation after exponentiation
(which follows multiplication, following addition).
For example, tetrate(5, 3) returns the result of 5 ** 5 ** 5: repeated exponentiation.
(Note that with ambiguous grouping, a ** b ** c is equal to a ** (b ** c).)
If there were a native JavaScript operator for tetration,
it might be a triple-asterisk: 5 *** 3.
Currently, there is only support for non-negative integer hyperexponents. Negative numbers and non-integers are not yet allowed.
tetrate(5, 3) // returns 5 ** 5 ** 5 // equal to 5 ** (5 ** 5)
tetrate(5, 1) // returns 5
tetrate(5, 0) // returns 1
the root, any number
the hyper-exponent to which the root is raised, a non-negative integer
informally, x *** n
if n is not a non-negative integer
Summary
Additional static members for the native Math class.
Description
Does not extend the native Math class.