How to portably force NAN * zero give zero in a particular expression without branching?

Viewed 368

(I feel like this should be a duplicate question, but I couldn't find the right search terms when searching.)

In general, (quiet) NAN times zero should give NAN -- and it does.

However, in one particular performance-critical part of my code, I want zero times anything to be zero.

What's a fast way to do this in C++?

2 Answers
Related