[Bug c/25498] New: atof conversion error

2005-12-19 Thread mike dot c at u-s-merchants dot com
char currConv[9];
float currConvf;
memset(currConv, '\0', sizeof(currConv));
memcpy(currConv, '60342935', 8);
currConv[8] = 0;
currConvf = atof(currConv);

// currConvf gets assigned value of 60342936 when string 60342935 is converted
to float with atof
// if currConvf is declared type double instead of float, the value is assigned
 // correctly:  60342935  (try in debugger)
// Thanks.


-- 
   Summary: atof conversion error
   Product: gcc
   Version: 4.2.0
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: mike dot c at u-s-merchants dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25498



[Bug c/25498] atof conversion error

2005-12-19 Thread mike dot c at u-s-merchants dot com


--- Comment #2 from mike dot c at u-s-merchants dot com  2005-12-20 00:21 
---
Subject: RE:  atof conversion error

Yes, but when I set the string to "60342935.00", I still get the same
result - 60342936 from atof() whereas if the covert to variable is
double (instead of float) I get the right result - 60342935.

I still think atof(##) should return the right result,
whatever the precision.

Thanks.

Mike Christen
[EMAIL PROTECTED]
310-261-1436


-Original Message-
From: pinskia at gcc dot gnu dot org [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 19, 2005 3:46 PM
To: [EMAIL PROTECTED]
Subject: [Bug c/25498] atof conversion error



--- Comment #1 from pinskia at gcc dot gnu dot org  2005-12-19 23:45
---
This is called float not having enough precession.  This is not a bug.
Please
read what floating point is.

The full testcase looks like:
#include 
#include 

#include 

int main(void)
{
char currConv[9];
float currConvf;
memset(currConv, '\0', sizeof(currConv));
memcpy(currConv, "60342935", 8);
currConv[8] = 0;
currConvf = atof(currConv);
printf("%f\n", currConvf);
}
-


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added


 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25498

--- You are receiving this mail because: ---
You are on the CC list for the bug, or are watching someone who is.
You reported the bug, or are watching the reporter.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25498