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

Discussion in 'C++' started by liam_herron, Aug 1, 2006.

  1. liam_herron

    liam_herron Guest

    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
     
    liam_herron, Aug 1, 2006
    #1
    1. Advertisements

  2. 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
     
    Victor Bazarov, Aug 1, 2006
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.