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
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