Thread: weird problem!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    167

    weird problem!

    i have a very weird problem with a float.
    i've read from a file a number:

    423.230000

    if i:
    Code:
    printf("%f ",tmp[*n].val+x);
    it prints me:
    423.230000 that is ok!
    tmp[*n].val is a float component of a structure containing the integer (423.00000) and x is a float containing 0.230000

    but if i do:
    Code:
    tmp[*n].val+=x;
    printf("%f ",tmp[*n].val);
    it prints me:
    423.230011
    Where does the 0.000011 comes from ?
    This problem occurs within a function!

    How can I fix it ?

    Thank you!
    Last edited by spank; 04-08-2006 at 02:01 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Problem With Pointer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2007, 07:50 PM
  2. Weird problem on '02 3.4L V6 auto
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 01-12-2006, 12:05 AM
  3. Really Weird itoa Problem
    By Grantyt3 in forum C++ Programming
    Replies: 8
    Last Post: 12-20-2005, 12:44 AM
  4. Replies: 6
    Last Post: 05-12-2005, 03:39 AM
  5. Weird class problem!
    By aker_y3k in forum C++ Programming
    Replies: 2
    Last Post: 09-25-2002, 06:12 AM