0.5
is a (negative) power of 2
, which means it is exactly representable by the IEEE-754 binary floating-point format. In signle precision it is 0'01111110'00000000000000000000000
.
Based on my quick tests with optimizations turned off (-O0
), it turns out that if y = 0.5 * x
, then y + y == x
. But is it always guaranteed by the IEEE-754 standard?
I know that in general if n
is a positive integer power of 2
, and m = 1.0 / n
, y = m * x
, then adding y
together n
times doesn't produce x
. But it seems that with n = 2
yes.
Do I miss something?