{{#items}}

{{text}}

{{/items}} {{ctaText}}

{{#items}} {{/items}}

showing results for - "cpp nan value"

Carolina

17 Jun 2018

```
1What is NaN ?
2NaN, acronym for “Not a Number” is an exception
3which usually occurs in the caseswhen an expression
4results in a number that can’t be represented.
5 For example square root of negative numbers.
6
7 // C++ code to demonstrate NaN exception
8#include<iostream>
9#include<cmath> // for sqrt()
10using namespace std;
11int main()
12{
13 float a = 2, b = -2;
14
15 // Prints the number (1.41421)
16 cout << sqrt(a) << endl;
17
18 // Prints "nan" exception
19 // sqrt(-2) is complex number
20 cout << sqrt(b) << endl;
21
22 return 0;
23}
24Output:
25
261.41421
27-nan
```

queries leading to this page

nan cppc 2b 2b detect nan valuenan is false c 2b 2bnan output in c 2b 2bnan c 2b 2b meaningdouble output nan cppwhat is nan c 2b 2bwhat does nan mean c 2b 2bcpp nan valuec 2b 2b how to get nannan in cppoutput nan c 2b 2bhow to get nan in c 2b 2bc 2b 2b set to nanhow to fix nan in c 2b 2bc 2b 2b nan 28ind 29using nan cpp nan 28ind 29 cppcheck for nan c 2b 2bwhat is nan in c 2b 2boutput is nan in c 2b 2bc 2b 2b create nan valuenan cpp meaningc 2b 2b nan instead of valuenan value c 2b 2b startvalue equal to nan c 2b 2bnan in c 2b 2bc 2b 2b not nanc 2b 2b nancpp nan typeref value nanna in cppcpp nannan data type c 2b 2bcpp nan outputnan cppc 2b 2b nan valueindex value as nan c 2b 2bnan c 2b 2bnan c 2b 2b examplenan in c 2b 2b4set value to nan c 2b 2bcpp nan value your answer for

you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content

please ensure to add code which is syntactically corrent and executes properly

ask question on maxinterview

you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content

please be clear, to the point and respectful