CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Posts
    30

    atof is not exact

    This is the code

    char number[]="0.58";
    double value = atof(number);

    When I execute it value is 0.57999999999999996

    Do you know why?

    Thanks in advance

  2. #2
    Join Date
    May 2006
    Location
    Norway
    Posts
    1,709

  3. #3
    Join Date
    Feb 2002
    Posts
    4,640

    Re: atof is not exact

    Yep. It has nothing to do with 'atof' but how floating point numbers are represented in a binary machine.

    Viggy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured