|
|
PHP round() - Math Functions
|
Tutorials » Php »
|
Topic |
What is round Function?
|
|
Explanation |
|
The "round()" function is used to round a float value to the nearest integer.
Syntax:
round(x,precision)
In the above syntax "x" is the floating number and "precision" specifies the number of digits after the decimal.
Example:
<?php
echo round(5.4);
echo round(5.5);
echo round(1.95583, 2);
echo round(1241757, -3);
echo round(5.045, 2);
?>
Result:
5
6
1.96
1242000
5.05
In the above example the "precision" values are provided for some digits, based on which the value is rounded to the nearest integer.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|