mrTux's blog

By mrTux, 11 years ago, In English

guys I was using double in my code but unexpectedly it's printed "nan" in output!!! can anyone tell me where did it originated form??

double y;

cout<<1-y; __ wrong output format Expected double, but "nan" found

  • Vote: I like it
  • -4
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it +2 Vote: I do not like it

There is special value of double called NaN (Not-a-number). It may be caused by disallowed operations i.e sqrt(-1).

»
11 years ago, # |
  Vote: I like it +1 Vote: I do not like it

In your case, it's probably due to division by zero (d) in y=p<n-1?0:u/d;. Weird...