Please help me

Please tell me, why 1.#QNAN displays in output when we have not write it in cout statment ???


Last edited on
1.#QNAN is the implementation and locale-dependant string representation of (quiet) NaN.

NaN: https://en.wikipedia.org/wiki/NaN
Display: https://en.wikipedia.org/wiki/NaN#Display

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

int main()
{
    float a = 1, b = 0 ;
    double c = 1, d = 0 ;
    long double e = 1, f = 0 ;

    std::cout << b/b << ' ' << d/d << ' ' << f/f << '\n' // 0.0/0 NaN
              << a/b << ' ' << c/d << ' ' << e/f << '\n'  // 1.0/0 infinity
              << -a/b << ' ' << -c/d << ' ' << -e/f << '\n' ; // -1.0/0 negative infinity
}

http://coliru.stacked-crooked.com/a/4dab56afdca9a65b
http://rextester.com/AEG64886
Last edited on
Topic archived. No new replies allowed.