• C

Generate NaN double value in c code running on windows

I'd like to generate a NaN value for a given double variable in c code running on windows.
I tried to do the following:
double d = sqrt(-1);
This code generates "-1.#IND00" instead of NaN when running on windows.
In Linux the same code generates NaN.


double d = sqrt(-1);
output => d => "-1.#IND00"

Open in new window

optimaltestAsked:
Who is Participating?
 
masheikConnect With a Mentor Commented:
Windows displays a NaN as -1.#IND  here, "IND" for "indeterminate"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.