避免转换为浮点数是必要的。
rust stable v1.61.0 分支:
ceil(a/b)
是 (a + b - 1) / b
如果你知道该添加不会溢出。
每晚:https://doc.rust-lang.org/std/primitive.i32.html#method.div_ceil
来自 Rust 标准库 div_ceil:
// pub const fn div_ceil(self, rhs: Self) -> Self;
// Calculates the quotient of self and rhs,
// rounding the result towards positive infinity.
let number: u32 = 122023;
let result = number.div_ceil(10000); // 13