Float Question

This is a discussion on Float Question within the C Programming forums, part of the General Programming Boards category; Hi, I have a problem I must do several arithmetics operations with integer decimals numbers but I have the following ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 08: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, 05:50 PM
  5. Multidimensional String
    By Beast() in forum C Programming
    Replies: 14
    Last Post: 07-03-2004, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21