Log in

View Full Version : Change a floating point number to higher integer



borris83
03-30-2009, 05:57 AM
Hi,

If I receive a decimal value 3.5 for a variable, is there any function to change it to 4, the nearest whole number...

I have the following code in a page:

$pages = mysql_num_rows($result)/7;

But if the value I receive for mysql_num_rows($result)/7 is a decimal number, I want to apply a function which will convert the floating point to the closest higher integer...

For eg, if it is 6.57 then the result should be 7;
If it is 19.3, then the result should be 20

codeexploiter
03-30-2009, 06:25 AM
You can use ceil function supported by PHP.

http://in2.php.net/manual/en/function.ceil.php

borris83
03-30-2009, 10:35 AM
Thanks, I have used ceil() and now I am able to complete my work