Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize decimal rounding in php

Shulou Source: shulou.com Published: 2022-06-03 10:49:34 09月26日 Update

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!

Tags: Functions types decimals variables syntax content numeric values articles integers methods learning help rounding characters strings tutorials data easy to understand more organized Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Redmi MySQL Shulou Technology Linux