You cannot do this, you need to return two variables, one for the value, one for the failure flag.
For example, you can set the value so that the function returns true in case of normal operation. false in case of failure (NaN).
A variable that stores the result is passed by reference as a parameter and will hold the return value if successful.
BOOL myFunction(int inInt, float inFloat, float *outResult) { /* PROCESSING HERE */ // in case of failure if( /* failure condition here */ ) { *outResult = 0; return false; } *outResult = /* your result */ return true; } // how to use the function int a; float b; float result; BOOL success; success = myFunction(a, b, &result); if(success) { // do whatever with your "result" } else { // NaN }
Paolo
source share