Question

Is floating point multiplication with 0.0 faster than average fp multiplication? The same question about adding 0.0 and multiplying with 1.0.

For the question to make exact sense: Is it faster on recent Intel CPUs?

Was it helpful?

Solution

No, not on modern hardware. Modern hardware can perform all normal double precision multiplications/additions/subtractions in one or two cycles. Possible exceptions to this are denormalized numbers and special values like +/-zero, +/-infinity, and NANs. These exceptions take longer if there is a difference.

However, as with all performance related questions, truth is only in measurements. If this is important to you, measure it, then you know what to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top