long double


If I compile (pgCC 6.1-6) and run the following code:

#include <iostream>

int main()
        using namespace std;
        double biggy = 1.0e307;
        cout << biggy << endl;
        return 0;

I get as output:


When I change



long double

then the output is


(or sometimes a “-” or nothing at all)

g++ seems to do it correct both times.

Hi Steabert,

Thanks for the report. It looks like a bug in the STL to me. I’ve submitted a technical problem report (TPR#3874) to our compiler team. Hopefully we’ll have a fix in the near future.

Although not very C++ like, the C ‘printf’ function using the ‘%g’ format does print the variable correctly. Also, ‘long double’ and ‘double’ are both 8 bytes so using ‘long double’ has no advantage over ‘double’.

  • Mat