Skip to main content

checked_div_floor

Function checked_div_floor 

Source
pub fn checked_div_floor(dividend: i64, divisor: i64) -> Option<i64>
Expand description

Returns the mathematical floor of dividend / divisor.

This helper follows floor semantics over signed integers instead of Rust’s truncating division semantics.

Returns None when divisor is zero or when the exact quotient does not fit in i64.

§Examples

use use_arithmetic::checked_div_floor;

assert_eq!(checked_div_floor(-7, 3), Some(-3));
assert_eq!(checked_div_floor(7, -3), Some(-3));
assert_eq!(checked_div_floor(7, 0), None);