Function dactyl::int_div_float

source ·
pub fn int_div_float<T: IntDivFloat>(e: T, d: T) -> Option<f64>
👎Deprecated since 0.6.0: use traits::IntDivFloat instead
Expand description

Integer to Float Division.

Recast two integers to floats, then divide them and return the result, or None if the operation is invalid or yields NaN or infinity.

This method accepts u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, and isize.

Examples

// Equivalent to 20_f64 / 16_f64.
assert_eq!(
    dactyl::int_div_float(20_u8, 16_u8),
    Some(1.25_f64)
);

// Division by zero is still a no-no.
assert!(dactyl::int_div_float(100_i32, 0_i32).is_none());