Re:Optimizations Enabled by -ffast-Math
by noctune on Wednesday October 20, 2021 @01:42PM
(#28933554)
>Calculating the average value for some observation in a time bucket, where some buckets may have no observation (resulting in 0/0=nan)
But there are many ways such a calculation could result in NaN besides a division. For example, intermediate sums could result in something like inf - inf. I find it rare that you can definitely conclude that a NaN means some specific thing.
NaN and Inf are extremely valuable and useful encodings to represent real things. Particularly signed infinity is wonderful, as functions like exp behave correctly for inf (eg. exp(-inf)=0).