Now that `Try{From|Into}`

have stabilized, have there been any discussions about how these might be implemented for `f{32|64}`

. It’s not obvious how (or if) you’d do it:

# Choices (e.g. `u64`

to `f64`

)

- Nearest match (no failure) - the conversion would pick the nearest f64 to the u64. This is undesirable IMO because the semantics don’t match expectations, and round-tripping would not be the identity (
`(big_num as f64) as u64 != big_num`

in all cases). - Fail on numbers bigger than
`(1<<53)-1`

- this is a conservative choice - there are some numbers bigger than`(1<<53)-1`

that can be represented as f64, but they are not dense (i.e. there are gaps). - (My preference I think) succeed if there is an f64 that is exactly equal to your u64, fail otherwise. Doing sums with your f64 will lead to errors, but that’s expected with f64 anyway.

I think that this should be implemented in some way (either `TryFrom`

or special methods), because as well as providing functionality, it gives us a place to raise this issue with the programmer. The programmer will search for the conversion, and then read the docs and learn about the intricacies of working with f64. In some ways I think this teaching opportunity is more important that actually providing the functionality.