Results 1 to 3 of 3

Thread: Change a floating point number to higher integer

  1. #1
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default Change a floating point number to higher integer

    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:
    Code:
     $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

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    You can use ceil function supported by PHP.

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

  3. The Following User Says Thank You to codeexploiter For This Useful Post:

    borris83 (03-30-2009)

  4. #3
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default

    Thanks, I have used ceil() and now I am able to complete my work

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •