Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
每当返回 NaN 时,我希望返回的值改为 0。实现此目的的最佳方法是什么?
你可以使用这个功能
float zero_nan(float n) { return n == n ? n : 0; }
您可以内联该函数并包装您认为可能是 nans 的任何返回值。