std::numeric_limits<double>::infinity() returns 0.0 on Intel/Linux g++ 3.2.3

L

liam_herron

Does anyone know why this is? Is there a compile flag to have this
return 'inf' as opposed to zero? Any help would be much appreciated.
I have included a sample program with sample output:


#include <limits>
#include <iostream>

using namespace std;


int main()
{
double x = -std::numeric_limits<double>::max();
double y = std::numeric_limits<double>::max();
double xNegInf = x*10;
double yInf = y*10.0;
double dInf = std::numeric_limits<double>::infinity();
cout << "Min: " << x << endl;
cout << "Max: " << y << endl;
cout << "Neg Inf: " << xNegInf << endl;
cout << "Inf: " << yInf << endl;
cout << "dInf: " << dInf << endl;
return 0;
}


-=-=-=-=-=-=-==-= Output -=-=-==-==-==-=-=-=-=-=

Min: -1.79769e+308
Max: 1.79769e+308
Neg Inf: -inf
Inf: inf
dInf: 0

-=-=-=-=-=-=-==-= End Output -=-=-==-==-==-=-=-=-=-=

Thanks,
Liam
 
V

Victor Bazarov

liam_herron said:
Does anyone know why this is? Is there a compile flag to have this
return 'inf' as opposed to zero? Any help would be much appreciated.
[..]

The makers of the library should know. Ask them. Try gnu.g++.help or
their online (web) forums. You could also try a third-party library
(like STLport), or just update your compiler (aren't they already at v4?)

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top