1

Whenever NaN is returned, I would like for the value returned to instead be 0. What is the best way to go about achieving this end?

Drew
  • 2,583
  • 5
  • 36
  • 54

1 Answers1

7

You can use this function

float zero_nan(float n)
{
  return n == n ? n : 0;
}

you can inline the function and wrap any return values you think may be nans.

Pavan Yalamanchili
  • 12,021
  • 2
  • 35
  • 55