SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Float to int

  1. #1
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Float to int

    How to round a float 92,2345 to int 92 ?

  2. #2
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you try http://us3.php.net/round ?

    There's also

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

    - and -

    http://us3.php.net/manual/en/function.floor.php

    However that does not handle strings such as "92,123" but does do 92.123
    Fesh
    imagine what it's going to be like

  3. #3
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like both functions do the same work.

    Is there any difference?

  4. #4
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA
    Looks like both functions do the same work.

    Is there any difference?
    Yes. Ceil() will round a fraction up no matter what it is. For example, 92.1000
    will always round up to 93.

    Floor() will always round down. So, 92.9999 will always round down to 92.

  5. #5
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by krayziepjf
    Yes. Ceil() will round a fraction up no matter what it is. For example, 92.1000
    will always round up to 93.

    Floor() will always round down. So, 92.9999 will always round down to 92.
    Thank you very much.


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
  •