This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
denormalized number problem under AIX
- From: "Eric Fernandez" <efernandez at physiomics-plc dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 27 Feb 2008 12:10:39 -0000
- Subject: denormalized number problem under AIX
Hi,
I face a problem when trying to convert string to double numbers, when
the string represents a denormalized number. I use g++ 4.2.2 on
powerpc-ibm-aix5.3.0.0.
Example:
-------------
#include <vector>
#include <sstream>
#include <iostream>
int main()
{
std::stringstream stream("5.6 0 0.205867 1.0809 7.22644 0.373206
-5.84675e-317 1.99995 0.00433641 1.45331e-45");
std::vector<double> vals;
double x;
while (stream >> x)
{
vals.push_back(x);
}
std::vector<double>::iterator it;
for (it=vals.begin(); it<vals.end(); it++) {
std::cout<<*it << " ";
}
return 0;
}
------------------
displays: 5.6 0 0.205867 1.0809 7.22644 0.373206
Interestingly, if I use:
--------------
double x;
std::string st;
while (stream >> st)
{
x = atof(st.c_str());
vals.push_back(x);
}
-------------
then that works, this displays: 5.6 0 0.205867 1.0809 7.22644 0.373206
-5.84675e-317 1.99995 0.00433641 1.45331e-45
I have seen there were some denormalized-related options for g++ on
Alpha, but they are not implemented on AIX. Moreover, some people
reported they don't see the issue with other compilers on other
platforms (aka VC++/Windows).
- Am I doing something wrong, or is there a bug there?
- Why does atof() work properly in that case?
Thanks
Eric