denormalized number problem under AIX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux