English

Integer Division by Constants: Optimal Bounds

Data Structures and Algorithms 2021-11-16 v3

Abstract

The integer division of a numerator n by a divisor d gives a quotient q and a remainder r. Optimizing compilers accelerate software by replacing the division of n by d with the division of c * n (or c * n + c) by m for convenient integers c and m chosen so that they approximate the reciprocal: c/m ~= 1/d. Such techniques are especially advantageous when m is chosen to be a power of two and when d is a constant so that c and m can be precomputed. The literature contains many bounds on the distance between c/m and the divisor d. Some of these bounds are optimally tight, while others are not. We present optimally tight bounds for quotient and remainder computations.

Keywords

Cite

@article{arxiv.2012.12369,
  title  = {Integer Division by Constants: Optimal Bounds},
  author = {Daniel Lemire and Colin Bartlett and Owen Kaser},
  journal= {arXiv preprint arXiv:2012.12369},
  year   = {2021}
}
R2 v1 2026-06-23T21:14:52.162Z