@divTrunc

@divTrunc

@divTrunc(numerator: T, denominator: T) T

Truncated division. Rounds toward zero. For unsigned integers it is the same as numerator / denominator. Caller guarantees denominator != 0 and !(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1).

  • @divTrunc(-5, 3) == -1
  • @divTrunc(a, b) + @rem(a, b) == a

For a function that returns a possible error code, use @import("std").math.divTrunc.

See also:

  • @divFloor
  • @divExact