In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to achieve digital rounding in js. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Digital rounding
If a number contains decimals, we want to remove decimals by using math.floor, math.ceil, or math.round methods to eliminate decimals. In fact, you can use the ~ operator to eliminate the decimal part of a number, which is much faster than those methods of numbers.
~ ~ 3.1415926 / / 3
In fact, this operator has many functions, usually used to convert variables to numeric types, and the conversion results vary from type to type:
If it is a string of numeric type, it will be converted to a pure number
If the string contains a value other than a number, it is converted to 0
If it is a Boolean, true returns 1, and false returns 0.
In addition to this method, we can also use bitwise and to realize the rounding operation of the number, just add "0" after the number:
23.9 | 0 / 23-23.9 | 0 / 23-23
This operation also directly removes the decimal after the number. This method is similar to the above method, and its performance is much better than JavaScript's API.
This is the end of the article on "how to achieve digital rounding in js". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.