pub fn pack_finite(
value: f64,
non_finite: &str,
out_of_range: &str,
) -> Result<f32, String>Expand description
Converts one f64 component into a packed f32, rounding to nearest.
Rejects non-finite input and values whose magnitude exceeds the finite
f32 range instead of silently truncating. Round-to-nearest is correct
for positions, colours and material scalars, where a half-ulp
difference is imperceptible.
§Arguments
f64- The value to narrow.&str- The error message for a non-finite value.&str- The error message for a value outside thef32range.
§Returns
Result<f32, String>- The narrowed value, or the applicable error.