Hi,

I don't know exactly when the change occurs (was it with gcc 4.1, 4.2,
4.3?), but I'm experiencing problems with the atof and strtof functions
since then.

In one of my C++ projects, I'm using atof to recover data from an ASCII file
to convert them into a float value. But,

string s( "0.549" );
cerr << atof( s ) << endl;    // Returns 0
cerr << atof( "0.513" ) << endl;     // Returns 0
cerr << atof( "1.117" ) << endl;    // Returns 1

I've tried to replace the calls to atof by calls to strtof. Same problem.
By contrast, a single test project with only the above lines of code gives
the expected results (i.e., 0.549, 0.513 and 1.117). So this may be due to
incorrect cascaded headers. I have #include <cstdlib> however.

I've also read this thread (
http://www.unix.com/high-level-programming/60607-interesting-implementation-atol-atof-etc.html),
but unfortunately, I don't get any compiler error or warning, so this may be
irrelevant.

This is on a hp workstation zx6000 running up-to-date Debian Testing with
gcc 4.3.1-2.
I can't reproduce this problem on an x86 PC, unfortunately not running
Debian, but with gcc 4.3.1 too.

Any idea what's going wrong? Thank you for any input.

     Émeric

Reply via email to