Case Analysis of JavaScript rounding
This article mainly explains the "case analysis of JavaScript rounding". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "JavaScript rounding case analysis".
The method of rounding in JavaScript: 1, rounding down through Math.floor (); 2, rounding up through Math.ceil (); 3, rounding up through Math.round (); 4, rounding through parseInt ().
This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.
How to round it up in JavaScript?
Several methods of JavaScript rounding
Math.floor () rounding down
Math.floor (3.141592654) / / 3
Math.ceil () rounding up
Math.ceil (3.141592654) / / 4
Math.round () is rounded
Math.round (3.141592654) / / 3
ParseInt () removes the decimal point and the decimal point
ParseInt (3.141592654) / / 3
~ convert data to Number type
~ 3.141592654 / / 3 Thank you for your reading. the above is the content of "JavaScript rounding case Analysis". After the study of this article, I believe you have a deeper understanding of the problem of JavaScript rounding case analysis, 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!