Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand JavaScript math

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

How to understand JavaScript math, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

JavaScript's Math object allows you to perform mathematical operations on numbers.

1. Mathematical function

1. Basic function

1.Math.PI

Project JavaScript Math.PI

Math.PI returns the ratio of the circumference to its diameter:

Document.getElementById ("demo") [xss_clean] = Math.PI

2. Math.round ()

Math.round (x) returns the value of x rounded to its nearest integer.

Project JavaScript Math.round ()

Math.round (x) returns the value of x rounded to its nearest integer:

Document.getElementById ("demo") [xss_clean] = Math.round (4.4)

3. Math.pow ()

Math.pow (x, y) x to the y power.

Document.getElementById ("demo") [xss_clean] = Math.pow (8. 2); / / returns 64

4. Math.sqrt ()

The square root of Math.sqrt (x) x.

Document.getElementById ("demo") [xss_clean] = Math.sqrt (64); / / returns 8

5. Math.abs ()

The absolute value of Math.abs (x) x.

Document.getElementById ("demo") [xss_clean] = Math.Math.abs (- 4.7); / / returns 4.7

6. Math.ceil ()

Math.ceil (x) returns the value of x rounded up to its nearest integer.

Document.getElementById ("demo") [xss_clean] = Math.ceil (4.4); / / returns 5

7. Math.floor ()

Math.floor (x) returns the value of x rounded down to its nearest integer.

Document.getElementById ("demo") [xss_clean] = Math.floor (4.7); / / does returns 4 help you after reading the above? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report