f



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

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

0
8/1/2006 1:52:16 PM
comp.lang.c++ 49423 articles. 7 followers. Post Follow

1 Replies
625 Views

Similar Articles

[PageSpeed] 32

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 


0
v.Abazarov (13256)
8/1/2006 1:56:54 PM
Reply: