Thread: Conversion of floating-point number

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    147

    Conversion of floating-point number

    How do I convert a floating point number to an integer, at the same time rounding up the number? not truncating it, but rounding it up...

    i forgot the function for it...
    Only by the cross are you saved...

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How do I convert a floating point number to an integer, at the same time rounding up the number?
    double d = 1.7;
    int i = (int)(d + .5);
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. floating point number comparison
    By stanlvw in forum C++ Programming
    Replies: 9
    Last Post: 04-27-2009, 01:44 PM
  2. floating point number printf/string formating
    By stanlvw in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2009, 04:41 PM
  3. For the numerical recipes in C types!
    By Smattacus in forum C Programming
    Replies: 5
    Last Post: 10-28-2008, 07:57 PM
  4. Getting a floating point exception
    By SnertyStan in forum C Programming
    Replies: 13
    Last Post: 03-25-2008, 11:00 AM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM