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,493
  • 5
  • 35
  • 52

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
  • 11,981
  • 2
  • 34
  • 55