cursive/src/div.rs

14 lines
280 B
Rust
Raw Normal View History

2015-05-22 23:57:29 +00:00
/// Integer division that rounds up.
pub fn div_up_usize(p: usize, q: usize) -> usize {
2015-05-15 00:48:24 +00:00
div_up(p as u32, q as u32) as usize
}
2015-05-22 23:57:29 +00:00
/// Integer division that rounds up.
pub fn div_up(p: u32, q: u32) -> u32 {
2016-03-15 22:37:57 +00:00
if p % q == 0 {
p / q
} else {
1 + p / q
}
}