How to use round in PHP

This article describe about round() Function in PHP.
  • 1286

round() Function

This function round to the floating point number into the nearest integer number.

Syntax

round( x, prec)

 

Parameter Description
x Specified number to be round
prec Specified the number of digit after floating point.

Example

<html>
<body>
<?php
echo(round(1.40) . "<br />");
echo(round(0.50) . "<br />");
echo(round(0.40) . "<br />");
echo(round(-5.20) . "<br />");
echo(round(-4.80))
?>
</body>
</html>

 

Output


round-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.