Dear internet: is casting from IEEE 754 single -> double -> single reliably non-lossy?

(Obviously double -> single on its own is.)

(Asking for canonicalization fun-times reasons, so this has security implications if wrong.)

Follow

@cwebber I think so. Afterall they only increase the coefficient and exponent continuation field. so a float should git cleanly within a double.

@cwebber @freemo it certainly mathematically should be possible to make it work, but I would not assume actual compilers necessarily do this without checking. I don't know the answer though.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.