Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the methods of the Math object

Shulou Source: shulou.com Published: 2022-06-03 00:19:53 10月03日 Update

This article mainly introduces "what are the methods of Math objects". In the daily operation, I believe that many people have doubts about the methods of Math objects. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "what are the methods of Math objects?" Next, please follow the editor to study!

1. Math.min ()

Math.min () is a function in the JS math library that returns the smallest of all passed values to the method.

Math.min (0,150,30,20,-8,200) / /-200

2. Math.max ()

The Math.max () method returns the larger of the two specified numbers.

Math.max (0,150,30,20,-8,200) / / 150

3. Math.round ()

The Math.round () function returns the nearest integer after a number is rounded.

Math.round / / 5 Math.round / / 4

4. Math.sqrt ()

The Math.sqrt () function returns the square root of a number, that is:

Math.sqrt (64) / 8 Math.sqrt (25) / / 5

5. Math.pow ()

The Math.pow () function returns the exponent power of the cardinality (base), that is:

Math.pow (8,2) / / 64

6. Math.floor ()

Math.floor () returns the largest integer less than or equal to a given number.

Math.floor / 4 Math.floor 8.6 / 8

7. Math.random ()

The Math.random () function returns a floating point with pseudorandom numbers ranging from 0 to less than 1, that is, up from 0 (including 0), but excluding 1 (excluding 1), and then you can zoom to the desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be selected or reset by the user.

Math.random () / 0.15497907645259867

8. Math.cos ()

The Math.cos () function returns the cosine of a numeric value.

Math.cos (0, Math.PI / 180) / 1

9. Math.sin ()

The Math.sin () function returns the sine of a numeric value.

Math.sin (90 * Math.PI / 180) / 1

The Math.ceil () function returns the smallest integer greater than or equal to a given number.

Math.ceil (4. 4) / / 5 at this point, the study of "what are the methods of Math objects" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Functions methods objects learning numbers integers minimum numeric more range random number help selection practical maximum larger rounded next two number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Shulou Tech Info Huawei Xiaomi