public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* denormalized number problem under AIX
@ 2008-02-27 12:51 Eric Fernandez
  0 siblings, 0 replies; only message in thread
From: Eric Fernandez @ 2008-02-27 12:51 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-27 12:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-27 12:51 denormalized number problem under AIX Eric Fernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).