std.math.divCeil: handle floats correctly
This commit is contained in:
@@ -624,6 +624,7 @@ fn testDivFloor() void {
|
||||
pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
|
||||
@setRuntimeSafety(false);
|
||||
if (numerator <= 0) return divTrunc(T, numerator, denominator);
|
||||
if (@typeInfo(T) == .Float) return @ceil(numerator / denominator);
|
||||
return (try divFloor(T, numerator - 1, denominator)) + 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user