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

What is the method of rounding javascript division

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

Share

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

This article mainly explains the "javascript division rounding method is what", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what is the method of javascript division rounding"!

The methods of javascript division rounding are as follows: 1, rounding is realized by round method; 2, upward rounding is realized by ceil method; 3, downward rounding is realized by floor method; 4, rounding is forced by parseInt.

This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.

What are the rounding methods of javascript division?

Four methods of rounding the results of javascript division

Math.round (7ap2) = 4 / / is rounded, and the round () method rounds a number to the nearest integer. Math.ceil (7ax 2) = 4 / / forces rounding up, and the ceil () method rounds the number up to the nearest integer and returns the result. If the parameter passed is an integer, the value is not rounded. Math.floor (7ax 2) = 3 / / forces rounding down, and the floor () method returns the largest integer less than or equal to x. If the passed parameter is an integer, the value remains unchanged parseInt (7 + 2) = 3 / / forcibly converted to a minimum integer, which is the same as the Math.floor method. The parseInt () function parses a string and returns an integer. Thank you for your reading, the above is the content of "what is the method of javascript division rounding". After the study of this article, I believe you have a deeper understanding of what the method of javascript division rounding is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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