Expand description
Get rounded result of an integer division.
§const fn rounded_div_*
assert_eq!(rounded_div::i32( 59, 4), 15); // 59/4 is equal to 14.75 which is closer to 15
assert_eq!(rounded_div::i32( 58, 4), 15); // 58/4 is equal to 14.5 which is rounded to 15
assert_eq!(rounded_div::i32( 57, 4), 14); // 57/4 is equal to 14.25 which is closer to 14
assert_eq!(rounded_div::i32(-59, 4), -15);
assert_eq!(rounded_div::i32(-58, 4), -15);
assert_eq!(rounded_div::i32(-57, 4), -14);
§trait RoundedDiv
use rounded_div::RoundedDiv;
assert_eq!( 59i32.rounded_div(4), 15); // 59/4 is equal to 14.75 which is closer to 15
assert_eq!( 58i32.rounded_div(4), 15); // 58/4 is equal to 14.5 which is rounded to 15
assert_eq!( 57i32.rounded_div(4), 14); // 57/4 is equal to 14.25 which is closer to 14
assert_eq!(-59i32.rounded_div(4), -15);
assert_eq!(-58i32.rounded_div(4), -15);
assert_eq!(-57i32.rounded_div(4), -14);
Re-exports§
pub use rounded_div_u8 as u8;
pub use rounded_div_u16 as u16;
pub use rounded_div_u32 as u32;
pub use rounded_div_u64 as u64;
pub use rounded_div_u128 as u128;
pub use rounded_div_usize as usize;
pub use rounded_div_i8 as i8;
pub use rounded_div_i16 as i16;
pub use rounded_div_i32 as i32;
pub use rounded_div_i64 as i64;
pub use rounded_div_i128 as i128;
pub use rounded_div_isize as isize;
Traits§
- Get rounded result of an integer division.
Functions§
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.
- Get rounded result of an integer division.