Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

divCeil

Divide numerator by denominator, rounding toward positive infinity. Returns an error on overflow or when denominator is zero.

math.divCeil
pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T

File

lib/std/math.zig:922

Code

pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
    @setRuntimeSafety(false);
    if (denominator == 0) return error.DivisionByZero;
    if (@typeInfo(T) == .int and numerator == minInt(T) and denominator == -1) {
        return error.Overflow;
    }
    return @divCeil(numerator, denominator);
}