Closed Thread
Results 1 to 2 of 2

Thread: Rounding floating point numbers

  1. #1
    anix's Avatar
    anix is offline Newbie
    Join Date
    Jan 2009
    Posts
    15
    Rep Power
    0

    Rounding floating point numbers

    Hey guys i've been scavenging google for a couple days now trying to find an answer to my question, but to no avail. So i'm gonna ask you guys here on the codecall forums.

    my question is, is it possible to round a floating point number up to the nearest whole number? and if so how to go about doing it.


    thanks
    -Anix

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    PythonPower's Avatar
    PythonPower is offline Programming Professional
    Join Date
    Feb 2009
    Posts
    228
    Rep Power
    13

    Re: Rounding floating point numbers

    Yes it is possible. And amazingly easy!

    Code:

    from math import ceil

    print(ceil(7.6))
    print(
    ceil(-1.4))
    print(
    ceil(-1.5))
    print(
    ceil(2.4)) 
    The function ceil() rounds up towards positive infinity. See this.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Floating point
    By ljl22 in forum C and C++
    Replies: 3
    Last Post: 03-22-2011, 07:43 AM
  2. Another floating point numbers question (C)
    By jcampos8782 in forum C and C++
    Replies: 5
    Last Post: 02-18-2011, 11:35 AM
  3. Floating point ...~
    By R3.RyozKidz in forum Java Help
    Replies: 3
    Last Post: 01-29-2010, 06:02 AM
  4. In need of floating point help
    By Ansems_keyblade in forum General Programming
    Replies: 3
    Last Post: 12-02-2009, 10:02 AM
  5. floating point variables in c/c++
    By avibiter in forum C and C++
    Replies: 1
    Last Post: 05-22-2009, 11:48 AM

Tags for this Thread

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