Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Math Functions

Some of the commonest functions used with the Math object are:

1. Math.random() => This returns a random number between 0 and 1. ex. 0.58346. It is heavily used for generating random ticket numbers, lottery, and other equivalent stuff.

2. Math.round(x) => rounds the decimal number X to the closest integer. ex. 0.5678 gets 1.

3. Math.ceil(x) =>  rounds the decimal X to the next integer. ex. 4.3 becomes 5

4. Math.floor(x) => rounds the decimal X to the previous integer. ex. 4.9 becomes 4.

5. Math.pow(x, y) => returns the result of X to the power of Y. ex Math.pow(10,3) = 1000

6. Math.sqrt(x) => returns the square root of number X.

7. math.abs(x) => returns the absolute value of the number X

8. Math.min(x, y, z) => returns the lowest number of a list of numbers. 

9. Math.max(x, y, z) => returns the biggest number of a list of numers

 

For full documentation list of functions see always here: