How to realize decimal rounding in php
This article mainly shows you "how to achieve decimal rounding php", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to achieve decimal rounding php" this article bar.
Methods: 1. Use intval() function, syntax "intval($num)";2. Use ceiling () function, syntax "ceiling ($num)";3. Use floor() function, syntax "floor($num)";4. Use round() function, syntax "round($num)".
Operating environment of this tutorial: Windows 7 system, PHP 7.1 version, DELL G3 computer
Php decimal rounding method
Use intval() function
The intval() function is used to obtain the integer value of a variable; it is often used to perform data type conversion, converting a string or floating point variable to an integer type.
2. Use the ceiling () function--round up, add 1 to the integer part if there are decimals
3. Use floor() function--round down
4. Use round() function-rounding
The above is "php how to achieve decimal rounding" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!