Home > Article > Backend Development > How to use php round function
PHP round() function is used to round floating point numbers. The round syntax is round(X,prec), the parameter X represents the number to be processed, and prec represents the number of digits after the decimal point.
#How to use the round() function?
Function: The function of round() function is to round floating point numbers
Syntax:
round(X,prec)
Parameters:
X means to do The processed number
prec represents the number of digits after the specified decimal point
Description: Returns the result of rounding the parameter 0 is the default value.
php round() function usage example 1:
<?php $i = 1.56; $i = round($i,2); $j = 5.25; $j = round($j,-1); $k = -5.35; $k = round($k); echo $i."*****".$j."*****".$k; ?>
Output:
1.56*****10*****-5
php round() function usage example 2:
<?php $i = -5.6; $j = round($i); echo $j; ?>
Output:
-6
This article is an introduction to the PHP round function. I hope it will be helpful to friends in need!
The above is the detailed content of How to use php round function. For more information, please follow other related articles on the PHP Chinese website!