Function divTrunc [src]

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

Prototype

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

Parameters

T: typenumerator: Tdenominator: T

Example

test divTrunc { try testDivTrunc(); try comptime testDivTrunc(); }

Source

pub fn divTrunc(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 @divTrunc(numerator, denominator); }