Thread: Float Question

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    5

    Float Question

    Hi, I have a problem
    I must do several arithmetics operations with integer decimals numbers but I have the following prolem :

    618 / 100.00 = 6.17999997

    and I need 6.1800 as result.

    I don't find the way to round the precision to 4 decimals .
    Does anybody know how to do this?

    Thanks in advance...

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Code:
    int main ( ) {
        float foo =  618 / 100.00;
        printf( "%.4f\n", foo );
        return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array and classes problem
    By armen in forum C++ Programming
    Replies: 9
    Last Post: 11-21-2008, 09:32 PM
  2. help me
    By warthog89 in forum C Programming
    Replies: 11
    Last Post: 09-30-2006, 08:17 AM
  3. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  4. Reflective Factory Design
    By Shamino in forum Game Programming
    Replies: 4
    Last Post: 12-16-2005, 06:50 PM
  5. Multidimensional String
    By Beast() in forum C Programming
    Replies: 14
    Last Post: 07-03-2004, 12:47 AM