Adds more functions to the native Math class in JavaScript.
Note: this library extends the native Math class of JavaScript, and therefore, there may be naming conflicts if other scripts add functions with the same names.
Math extended adds the following contstants:
- Square Root of 3,
- Square Root of 5,
- Square Root of 6,
- Square Root of 10,
- Phi (a.k.a. Golden Ratio),
- Silver Ratio.
It also adds the following functions:
isInt
- checks if a number is an integer,randomBetween
- generates a random number betweena
andb
,roundTo
- rounds a number to specified decimal places,square
- raises the number to the second power,cube
- raises the number to the third power,factorial
- calculates the factorial ofn
,fallingFactorial
- calculates the falling factorial ofn
withk
steps,binomialCoefficient
- calculates the binomial coefficient (n
choosek
),gcd
- calculates the greatest common divisor of two integers,lcm
- calculates the least common multiple of two integers,average
- calculates the average of the given numbers,weightedAcerage
- calculates the weighted average of the given numbers,geometricMean
- calculates the geometric mean (geometric average) of the given numbersmean
- calculates the mean of the given numbers,variance
- calculates the variance of a set of numbers,standardDeviation
- calculates the standard deviation of a set of numbers.
See Getting Started.
To install MathExtended on the web client, include this script tag in your document, (above other scripts).
<script src="https://joker876.github.io/MathExtended/dist/math-extended.min.js"></script>