Click here to Skip to main content
15,867,904 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to return a null pointer in c++
The expression "return NaN" is not valid!
Posted

1 solution

C++
return NULL

or

C++
return 0;
 
Share this answer
 
Comments
[no name] 17-Apr-12 5:08am    
Does it get any easier?
Sumal.V 17-Apr-12 5:14am    
Null, nullptr or 0 returns "0". But I have to return NaN! Are they all the same? Just wondering when there is an expression to check Nan ie: _isnan there should be something to return the same.

[no name] 17-Apr-12 5:20am    
You cannot return a NaN as such e.g 1/0. Sometimes -9999999999999 is returned to flag a NaN. Can you post some code to see what you are trying to do?
Sumal.V 17-Apr-12 5:26am    
Okay. Its a piece of code from the vincenty Inverse Solution. This is in Java script

var iterLimit = 100;

if (iterLimit==0) return NaN // formula failed to converge
Sumal.V 17-Apr-12 5:27am    
* There is a decrement operator for the iterLimit prior to this in a while loop

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900