Tuesday, November 25, 2008

How to round a floating point number in php - round()

Following code will show you several examples on how to round a floating numeric value as you like.


echo round(10.8); // 11
echo '<br />';
echo round(10.4); // 10
echo '<br />';

/*you can also set the number of precision,
or in other words number of decimal digits
you like to round the floating number

echo round(10.837, 2); // 10.84
echo '<br />';
echo round(10.435767, 4); // 10.4358
echo '<br />';


Get Free Sinhala IT Learning Videos Kuppiya.com

Get custom programming done at GetAFreelancer.com!

No comments:

Post a Comment