This repository was archived by the owner on Dec 10, 2023. It is now read-only.

Description
I was surprised to discover this:
x = Float16(0.992)
y = Float16(6.0e-8) # subnormal
julia> d = Single(x)*Single(y)
Double(6.0e-8, 0.0)
- value: 5.9604644775390625e-08
julia> bits(widen(d.hi) + widen(d.lo))
"00110011100000000000000000000000"
julia> bits(widen(x)*widen(y))
"00110011011111100000000000000000"
It can be fixed this way:
julia> ys, ye = frexp(y)
(Float16(0.5), -23)
julia> d = Single(x)*Single(ys)
Double(0.496, 0.0)
- value: 0.49609375
julia> bits(ldexp(widen(d.hi) + widen(d.lo), ye))
"00110011011111100000000000000000"
But given that many treatises say "it's exact unless the splitting overflows," this was a surprising discovery to me.