By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,411 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,411 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Aug 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
liam_herron wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.