Ask HN: How is it possible to get -0.0 in a sum?
7 gus_massa 1 8/2/2025, 1:58:43 PM
I'm looking for corner cases where he result is -0.0. As far as I know, the only way to get -0.0 in a sum is
(-0.0) + (-0.0)
Does someone know any other case in IEEE 754?Bonus question: What happens in subtractions? I only know
(-0.0) - (+0.0)
Is there any other case?
Here's an example of -1.0f + 1.0f resulting in -0.0: https://godbolt.org/z/z853nWMqa
NB: If using C23 you can use:
Which would be more portable. I just edited the CSR directly because godbolt was complaining about undefined reference to `fesetround` even with -std=c23.