You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to introduce lossless TryFrom implementations for bf16 and f16 types from Rust primitive f32 and f64 types so that for example f16::try_from(value).map(f16::to_f32) is either Err or Ok(value2) with value == value2 for all possible values?
This means that if TryFrom is Ok the conversion was lossless and it is possible to fully recover the f32 or f64 value later on if no mutations happen in between. If TryFrom yields Err then it is not possible to losslessly convert the particular f32 or f64 value. No rounding shall take place.
I actually need this if this can be implemented efficiently. :)
The text was updated successfully, but these errors were encountered:
This adds `from_f*_lossless` functions, which then are implemented as `TryFrom`, which will only return values if they can fully roundtrip.
Related to starkat99#90
This adds `from_f*_lossless` functions, which then are implemented as `TryFrom`, which will only return values if they can fully roundtrip.
Related to starkat99#90
@Robbepop not sure if there's still interest but I implemented this and would gladly make a PR here. It's not too complicated or inefficient, but it does need special handling of denormals and overflow.
It will roundtrip for anything besides signaling NaNs, which will be returned as a NaN (either quiet or signaling depending on context), and it's not much less efficient or is as efficient compared to the software conversion functions.
Would it be possible to introduce lossless
TryFrom
implementations forbf16
andf16
types from Rust primitivef32
andf64
types so that for examplef16::try_from(value).map(f16::to_f32)
is eitherErr
orOk(value2)
withvalue == value2
for all possiblevalue
s?This means that if
TryFrom
isOk
the conversion was lossless and it is possible to fully recover thef32
orf64
value later on if no mutations happen in between. IfTryFrom
yieldsErr
then it is not possible to losslessly convert the particularf32
orf64
value. No rounding shall take place.I actually need this if this can be implemented efficiently. :)
The text was updated successfully, but these errors were encountered: