Function divFloor [src]

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

Prototype

pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T

Parameters

T: typenumerator: Tdenominator: T

Example

test divFloor { try testDivFloor(); try comptime testDivFloor(); }

Source

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