Repository navigation
Half-float preserve more bits for denormals - #208
Conversation
|
Hi @ranvis, thank you for the patch! This is a breaking change, so I'd like to understand the benefit. Do you have some real-world usecase(s) for keeping more bits? |
|
The patch will make it possible to round-trip half-float values. |
|
Got it, thanks. Having encode and decode functions composing to identity (up to the float => half float data loss) sounds like a good argument. Brief search doesn't show anyone relying on the half, so let's go ahead with this. Thanks a lot for the improvement! |
PR: Half-float preserve more bits for denormals
Description
Encoding of half-float values that is in range of denormalized numbers had been trimmed the whole mantissa bits.
This patch improves it by reflecting some bits to the encoded value.
Some examples:
I used "round half away from zero" instead of "round to even" because it is simple and doesn't need an execution branch.
Checklist