rsqrtf(0.0) returns inf instead of NaN

Is there any way I can get rqrtf(0.0) to return a NaN instead of an inf so I can use fmaxf and fminf to weed out the invalid results? This is what I want to do in a nutshell:

d = dxdx+dydy+dzdz;
d=rsqrtf(d);
if(d is inf) d=0;
result+=d
multfact;

If rqsrtf returned a NaN, from what I read from the programming manual, I could fmaxf(0.0,d) it to get rid of the divergent if statement. Sadly, it doesn’t work in case of an inf.

Thanks

EDIT: I just realized NaNs are not supposed to be the result of division by zero, but any help with getting rid of the divergent if will be appreciated nonetheless

It’s solved. For anyone interested, here is what I did:

d = fmaxf(d+(d-d),0.0);

If d is inf, (d-d) returns a NaN and 0.0 otherwise. There is no noticeable loss in performance by using this. (No divergence)

Elegant.

For the record: Before I saw the solution, I was thinking to suggest you try bitwise comparing the INF’s.