In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "jquery division how to take the decimal places", the article explains the content 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 "jquery division how to take the decimal places" bar!
Methods: 1, use the toFixed () method to take two decimal places, this method can be rounded to the specified decimal places, the syntax is "division result .tofixed (2)"; 2, the use of round () method to take the last two decimal places, the syntax is "Math.round (division result * 100) / 100".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
How to take the last two decimal places in jquery by division
1. The toFixed () method rounds Number to a specified number of decimal places.
Grammar
NumberObject.toFixed (num)
Num is required. The specified number of decimal places is a value between 0 and 20, including 0 and 20, and some implementations can support a wider range of values. If this parameter is omitted, 0 will be used instead.
Return value
Returns the string representation of NumberObject, instead of exponential counting, with fixed num digits after the decimal point. If necessary, the number is rounded, or it can be filled with 0 so that it reaches the specified length. If num is greater than le+21, the method simply calls NumberObject.toString () and returns the string represented by exponential counting.
Examples are as follows:
Var x = 7 demo var y = 8 politic var z = x / y politic var result = z.toFixed (2); document.getElementById ("demo") [xss_clean] = result
Output result:
2. The round () method rounds a number to the nearest integer.
Grammar
Math.round (x)
X required. It has to be a number.
Return value
The integer closest to x.
Description
For 0.5, this method rounds up.
For example, 3.5 will be rounded to 4 and-3.5 will be rounded to-3.
Examples are as follows:
Var x = 7 position var y = 8 xss_clean z = x / y politics var result = Math.round (Zhen100) / 100 scape document.getElementById ("demo") [xss_clean] = result
Output result:
Thank you for your reading, the above is the content of "how to take the last two decimal places in jquery division". After the study of this article, I believe you have a deeper understanding of how division in jquery takes the last two decimal places, 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.
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.