pub const fn ceil_div_usize(a: usize, divisor: usize) -> usize {
a / divisor + (a % divisor != 0) as usize
}
pub const fn shr64(a: u64, shift: usize) -> u64 {
if shift < 64 {
a >> shift
} else {
0
}
}
#[allow(dead_code)]
pub const fn shl64(a: u64, shift: usize) -> u64 {
if shift < 64 {
a << shift
} else {
0
}
}
pub const fn carrying_add(lhs: u64, rhs: u64, carry: bool) -> (u64, bool) {
let (a, b) = lhs.overflowing_add(rhs);
let (c, d) = a.overflowing_add(carry as u64);
(c, b | d)
}
pub const fn bit_mask_lsb_u64(n: usize) -> u64 {
let mut mask = !0_u64;
if n < 64 {
mask = mask.wrapping_add(1_u64 << n);
}
mask
}
pub const fn blsi_u64(v: u64) -> u64 {
v & v.wrapping_neg()
}
#[allow(dead_code)]
pub const fn blsr_u64(v: u64) -> u64 {
v & v.wrapping_sub(1)
}