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 are NaNs equal for this canonicalization or do they not occur in your domain? (these casts seem to preserve their bit patterns, but a NaN is not equal to itself, so it's not lossy unless using floating point equality checks)

@mtjm NaNs are not defined or supported in this canonicalization (or rather, you'd have to use the extension type to represent them) so "that's our answer for now thank god"

But I should explicitly document that :)

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!