faq 1.#QNAN00000000 and -1.#IND000000000

Discussion in 'C++' started by fcvcnet, Nov 1, 2006.

  1. fcvcnet

    fcvcnet Guest

    Hi,
    I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
    happened?
    why?
    Thanks.
    fcvcnet, Nov 1, 2006
    #1
    1. Advertising

  2. fcvcnet

    Kavya Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    fcvcnet wrote:
    > Hi,
    > I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
    > happened?
    > why?


    If you can post your code then it might be more easy to find the
    problem.
    Kavya, Nov 1, 2006
    #2
    1. Advertising

  3. fcvcnet

    Jim Langston Guest

    "fcvcnet" <> wrote in message
    news:ei9ndm$5lf$99.com...
    > Hi,
    > I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
    > happened?
    > why?
    > Thanks.


    NAN is not a number. This can happen with a floating point math won't work.
    In some cases dividing by 0 will produce a NAN, but in others it produces
    infinity (not sure if the specs say whiat it should produce).

    Not sure what IND is. It may be infinity, but I would think that would be
    INF, so I'm not sure.
    Jim Langston, Nov 1, 2006
    #3
  4. fcvcnet

    Marcus Kwok Guest

    Jim Langston <> wrote:
    > "fcvcnet" <> wrote in message
    > news:ei9ndm$5lf$99.com...
    >> Hi,
    >> I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
    >> happened?
    >> why?
    >> Thanks.

    >
    > NAN is not a number. This can happen with a floating point math won't work.
    > In some cases dividing by 0 will produce a NAN, but in others it produces
    > infinity (not sure if the specs say whiat it should produce).
    >
    > Not sure what IND is. It may be infinity, but I would think that would be
    > INF, so I'm not sure.


    I'm not sure either, but IND might mean "indeterminate". As in,
    (informally) 1/0 is infinity but 0/0 is indeterminate.

    http://mathworld.wolfram.com/Indeterminate.html

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply
    Marcus Kwok, Nov 1, 2006
    #4
  5. fcvcnet

    Geo Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    fcvcnet wrote:
    > Hi,
    > I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
    > happened?
    > why?
    > Thanks.


    recently I had to do some experimentation with this stuff, here's some
    code and the output


    float pinf = std::numeric_limits<float>::infinity();
    double dpinf = std::numeric_limits<double>::infinity();

    float ninf = -std::numeric_limits<float>::infinity();
    float zero = 0.0;
    float NaN = std::numeric_limits<float>::quiet_NaN();
    float nNaN = -std::numeric_limits<float>::quiet_NaN();
    double dNaN = std::numeric_limits<double>::quiet_NaN();

    float xNaN = static_cast<float>(dNaN);

    std::cout << "+ve infinity " << pinf << "\n";
    std::cout << "-ve infinity " << ninf << "\n";
    std::cout << "+ve QNAN " << NaN << "\n";
    std::cout << "+ve dQNAN " << dNaN << "\n";
    std::cout << "+ve xQNAN " << xNaN << "\n";
    std::cout << "-ve QNAN " << nNaN << "\n";
    std::cout << "+inf = +inf " << (pinf == pinf) << "\n";
    std::cout << "+inf <= +inf " << (pinf <= pinf) << "\n";
    std::cout << "+inf = +dinf " << (pinf == dpinf) << "\n";
    std::cout << "+inf = -inf " << (pinf == ninf) << "\n";
    std::cout << "+inf / +inf " << pinf/pinf << "\n";
    std::cout << "+inf / -inf " << pinf/ninf << "\n";
    std::cout << "+inf / zero " << pinf/zero << "\n";
    std::cout << "+inf * -inf " << pinf*ninf << "\n";
    std::cout << "+inf + -inf " << pinf+ninf << "\n";
    std::cout << "+inf + +inf " << pinf+pinf << "\n";
    std::cout << "+inf - -inf " << pinf-ninf << "\n";
    std::cout << "+inf - +inf " << pinf-pinf << "\n";
    std::cout << "-inf - -inf " << ninf-ninf << "\n";
    std::cout << "\n\n";
    std::cout << "NaN = NaN " << (NaN == NaN) << "\n";
    std::cout << "-NaN = -NaN " << (nNaN == nNaN) << "\n";
    std::cout << "-NaN = NaN " << (nNaN == NaN) << "\n";
    std::cout << "NaN = -NaN " << (NaN == nNaN) << "\n";
    std::cout << "NaN = +inf " << (NaN == pinf) << "\n";
    std::cout << "NaN = -inf " << (NaN == ninf) << "\n";
    std::cout << "0 / zero " << 0/zero << "\n";

    +ve infinity 1.#INF
    -ve infinity -1.#INF
    +ve QNAN 1.#QNAN
    +ve dQNAN 1.#QNAN
    +ve xQNAN 1.#QNAN
    -ve QNAN -1.#IND
    +inf = +inf 1
    +inf <= +inf 1
    +inf = +dinf 1
    +inf = -inf 0
    +inf / +inf -1.#IND
    +inf / -inf -1.#IND
    +inf / zero 1.#INF
    +inf * -inf -1.#INF
    +inf + -inf -1.#IND
    +inf + +inf 1.#INF
    +inf - -inf 1.#INF
    +inf - +inf -1.#IND
    -inf - -inf -1.#IND


    NaN = NaN 0
    -NaN = -NaN 0
    -NaN = NaN 0
    NaN = -NaN 0
    NaN = +inf 0
    NaN = -inf 0
    0 / zero -1.#IND
    Geo, Nov 1, 2006
    #5
  6. fcvcnet

    Geo Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    Meant to say, results are from gcc on pentium, and seem to agree with
    IEEE 754. VC 6.0 results differ for some cases, VC 7.0 is the same as
    gcc.
    Geo, Nov 1, 2006
    #6
  7. fcvcnet

    fcvcnet Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    Thanks you very much.

    "Geo" <>
    ??????:...
    > Meant to say, results are from gcc on pentium, and seem to agree with
    > IEEE 754. VC 6.0 results differ for some cases, VC 7.0 is the same as
    > gcc.
    >
    fcvcnet, Nov 2, 2006
    #7
  8. fcvcnet

    fcvcnet Guest

    Thanks you very much.
    "Marcus Kwok" <> дÈëÏûÏ¢ÐÂÎÅ:eiagra$8dp$...
    > Jim Langston <> wrote:
    >> "fcvcnet" <> wrote in message
    >> news:ei9ndm$5lf$99.com...
    >>> Hi,
    >>> I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme,
    >>> what
    >>> happened?
    >>> why?
    >>> Thanks.

    >>
    >> NAN is not a number. This can happen with a floating point math won't
    >> work.
    >> In some cases dividing by 0 will produce a NAN, but in others it produces
    >> infinity (not sure if the specs say whiat it should produce).
    >>
    >> Not sure what IND is. It may be infinity, but I would think that would
    >> be
    >> INF, so I'm not sure.

    >
    > I'm not sure either, but IND might mean "indeterminate". As in,
    > (informally) 1/0 is infinity but 0/0 is indeterminate.
    >
    > http://mathworld.wolfram.com/Indeterminate.html
    >
    > --
    > Marcus Kwok
    > Replace 'invalid' with 'net' to reply
    fcvcnet, Nov 2, 2006
    #8
  9. fcvcnet

    fcvcnet Guest

    Thanks you very much.

    "Jim Langston" <> дÈëÏûÏ¢ÐÂÎÅ:Cz_1h.69$...
    > "fcvcnet" <> wrote in message
    > news:ei9ndm$5lf$99.com...
    >> Hi,
    >> I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme,
    >> what happened?
    >> why?
    >> Thanks.

    >
    > NAN is not a number. This can happen with a floating point math won't
    > work. In some cases dividing by 0 will produce a NAN, but in others it
    > produces infinity (not sure if the specs say whiat it should produce).
    >
    > Not sure what IND is. It may be infinity, but I would think that would be
    > INF, so I'm not sure.
    >
    fcvcnet, Nov 2, 2006
    #9
  10. fcvcnet

    fcvcnet Guest

    fcvcnet, Nov 2, 2006
    #10
  11. fcvcnet

    cts Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    Odd that no one seems to have brought up errno.

    When something in the C libraries, like the math library, fails, the
    global variable errno is set. If you get a value of #QNAN or #IND,
    it's likely that an error in the standard math library. You can easily
    check this after an operation and you can get a nice string
    representation of the error message too.

    example:

    #include <cmath>
    #include <cstring>
    #include <iostream>

    errno = 0; // clear out any previous errors

    // example math call
    y = std::atan(x); // we suspect that something screwy happens here,
    maybe 'x' is a bad value

    // check if there was a catastrophe, if yes, print out the error
    message
    if (errno)
    std::cout << strerror(errno) << std::endl;

    fcvcnet wrote:
    > Hi,
    > I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme, what
    > happened?
    > why?
    > Thanks.
    cts, Nov 2, 2006
    #11
  12. fcvcnet

    fcvcnet Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    Thanks you very much.

    "cts" <>
    ??????:...
    > Odd that no one seems to have brought up errno.
    >
    > When something in the C libraries, like the math library, fails, the
    > global variable errno is set. If you get a value of #QNAN or #IND,
    > it's likely that an error in the standard math library. You can easily
    > check this after an operation and you can get a nice string
    > representation of the error message too.
    >
    > example:
    >
    > #include <cmath>
    > #include <cstring>
    > #include <iostream>
    >
    > errno = 0; // clear out any previous errors
    >
    > // example math call
    > y = std::atan(x); // we suspect that something screwy happens here,
    > maybe 'x' is a bad value
    >
    > // check if there was a catastrophe, if yes, print out the error
    > message
    > if (errno)
    > std::cout << strerror(errno) << std::endl;
    >
    > fcvcnet wrote:
    >> Hi,
    >> I got result 1.#QNAN00000000 and -1.#IND000000000 in my programme,
    >> what
    >> happened?
    >> why?
    >> Thanks.

    >
    fcvcnet, Nov 3, 2006
    #12
  13. fcvcnet

    fcvcnet Guest

    Re: faq 1.#QNAN00000000 and -1.#IND000000000

    #include "stdafx.h"
    #include <cmath>
    #include <cstring>
    #include <iostream>

    int main(int argc, char* argv[])
    {
    errno = 0;
    double i,j;
    i=1;
    j=0;
    double y = i/j;
    if (errno)
    std::cout << strerror(errno) << std::endl;
    std::cin >> i;
    return 0;
    }
    I tried , but I saw nothing. My code right?
    fcvcnet, Nov 3, 2006
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-15?Q?Juli=E1n?= Albo

    FAQ or not FAQ?

    =?ISO-8859-15?Q?Juli=E1n?= Albo, Jan 8, 2007, in forum: C++
    Replies:
    28
    Views:
    863
    Grizlyk
    Jan 15, 2007
  2. Replies:
    1
    Views:
    526
    Flash Gordon
    Nov 13, 2009
  3. Josef 'Jupp' Schugt
    Replies:
    0
    Views:
    199
    Josef 'Jupp' Schugt
    Sep 22, 2003
  4. FAQ server

    FAQ - How do I direct someone to this FAQ?

    FAQ server, Aug 4, 2006, in forum: Javascript
    Replies:
    1
    Views:
    157
    Dr John Stockton
    Aug 4, 2006
  5. Peter Michaux

    FAQ/FAQ notes site makeover

    Peter Michaux, Nov 22, 2006, in forum: Javascript
    Replies:
    22
    Views:
    355
    Randy Webb
    Nov 27, 2006
Loading...

Share This Page