Casting from an f64 to an f32 will produce the closest possible f32 **
if necessary, rounding is according to roundTiesToEven mode ***
on overflow, infinity (of the same sign as the input) is produced
** if f64-to-f32 casts with this rounding mode and overflow behavior are not supported natively by the hardware, these casts will likely be slower than expected.
*** as defined in IEEE 754-2008 §4.3.1: pick the nearest floating point number, preferring the one with an even least significant digit if exactly halfway between two floating point numbers.
The RFC for TryFrom was 1542. The topic was discussed here: GitHub. Casts involving floats were ultimately dropped including TryFrom for f64 -> f32. In my naive take, I suspect it has to do with a lack of a clear line for when to throw an error and method for rounding down to the f32 value in a canonical way.
I base this loosely on the authors’ referencing also not having f32 -> i32 because of a loss of precision.
For u64 -> u32 it’s clear when it makes sense to throw an error. Before the error needs to be thrown the values are semantically identical. That can’t be said for floats. The extra precision in a f64 vs a f32 actually means something - always. So, when do you throw an error, and how do you treat the loss of precision? There are ways, but none that are canonical.
There are the IEEE Floating Point flags, one of which is inexact, but I don't know if the libraries provide a way to set and check the flags. If there was, you could clear inexact, do the cast, and return an error if inexact was set. If inexact is set on conversions, that is.