# Faster remainder by direct computation: Applications to compilers and software libraries

@article{Lemire2019FasterRB, title={Faster remainder by direct computation: Applications to compilers and software libraries}, author={Daniel Lemire and Owen Kaser and Nathan Kurz}, journal={Software: Practice and Experience}, year={2019}, volume={49}, pages={953 - 970} }

On common processors, integer multiplication is many times faster than integer division. Dividing a numerator n by a divisor d is mathematically equivalent to multiplication by the inverse of the divisor (n/d=n∗1/d). If the divisor is known in advance, or if repeated integer divisions will be performed with the same divisor, it can be beneficial to substitute a less costly multiplication for an expensive division. Currently, the remainder of the division by a constant is computed from the… Expand

#### Topics from this paper

#### Paper Mentions

#### 8 Citations

A 32-bit Integer Division Algorithm Based on Priority Encoder

- Computer Science
- 2020 27th IEEE International Conference on Electronics, Circuits and Systems (ICECS)
- 2020

An algorithm for 32-bit integer division of positive and negative dividends and divisors represented in sign and magnitude is proposed and its functionality was verified by ModelSim simulations. Expand

Padding in the mathematics of arrays

- 2021

Multi-dimensional array manipulation constitutes a core component of numerous numerical methods, e.g. finite difference solvers of Partial Differential Equations (PDEs). The efficiency of such… Expand

Euclidean Affine Functions and Applications to Calendar Algorithms

- Computer Science
- ArXiv
- 2021

The main application presented in this article relates to Gregorian calendar algorithms and it is shown how they can be implemented substantially more efficiently than is currently the case in widely used C, C++, C# and Java open source libraries. Expand

A Constant Time Full Hardware Implementation of Streamlined NTRU Prime

- Computer Science
- IACR Cryptol. ePrint Arch.
- 2020

This work implements the entire KEM algorithm, including all steps for key generation, encapsulation and decapsulation, and all enand decoding, in a constant time hardware implementation of the NIST round 2 post-quantum cryptographic algorithm Streamlined NTRU Prime. Expand

MUSE: Multi-Use Error Correcting Codes

- Computer Science
- ArXiv
- 2021

In this work we present a new set of error correcting codes – Multi-Use Error Correcting Codes (MUSE ECC) – that have the ability to match reliability guarantees of all commodity, conventional… Expand

Integer division by constants: optimal bounds

- Medicine, Computer Science
- Heliyon
- 2021

This work presents optimally tight bounds for quotient and remainder computations for convenient integers c and m chosen so that they approximate the reciprocal: c/m≈1/d. Expand

Number parsing at a gigabyte per second

- Computer Science
- Softw. Pract. Exp.
- 2021

By combining the significand and precomputed tables, the solution to the problem of parsing decimal numbers to the nearest binary floating‐point value can be several times faster than conventional functions present in standard C libraries on modern 64‐bit systems. Expand

c-Trie++: A Dynamic Trie Tailored for Fast Prefix Searches

- Computer Science, Mathematics
- 2020 Data Compression Conference (DCC)
- 2020

This work proposes a keyword dictionary that represents K in n lg σ + Θ (k lg n) bits of space, supporting all operations in Θ(m / α + lg α) expected time on an input string of length m in the word RAM model. Expand

#### References

SHOWING 1-10 OF 22 REFERENCES

Efficient Algorithms for Integer Division by Constants Using Multiplication

- Computer Science, Mathematics
- Comput. J.
- 2008

This analysis leads to the discovery of a limit to the straightforward application of this method in the form of a critical dividend, which fortunately associates with a minority of the possible divisors and defines only a small upper part of the available dividend space. Expand

Improved Division by Invariant Integers

- Mathematics, Computer Science
- IEEE Transactions on Computers
- 2011

An algorithm is described that produces a quotient and remainder using one umul and one umullo, which is an improvement over earlier methods, since the new method uses cheaper multiplication operations. Expand

Hardware Division by Small Integer Constants

- Computer Science, Mathematics
- IEEE Transactions on Computers
- 2017

The article studies whether the division by the product of two constants is better implemented as two successive dividers or as one atomic divider, and considers the case when only a quotient or only a remainder is needed. Expand

Division by invariant integers using multiplication

- Computer Science
- PLDI '94
- 1994

This paper presents code sequences for division by arbitrary nonzero integer constants and run-time invariants using integer multiplication using a two's complement architecture, and treats unsigned division, signed division, and division where the result is known a priori. Expand

Efficient and formally proven reduction of large integers by small moduli

- Computer Science, Mathematics
- TOMS
- 2010

This work presents a modular reduction algorithm implementing division by a modulus through multiplication by a reciprocal of that modulus, a well-known method for moduli larger than 2w-1, and shows that application of this method to smaller moduli makes it possible to express certain modular sums and differences without having to compensate for word overflows. Expand

Constant-division algorithms

- Mathematics
- 1994

There exist many types of special-purpose systems that require rapid and repeated division by a set of known constant divisors. Numerous solutions have been proposed in response to the deficiencies… Expand

A Combinatoric Division Algorithm for Fixed-Integer Divisors

- Mathematics, Computer Science
- IEEE Trans. Computers
- 1973

A procedure is presented for performing a combinatoric fixed-integer division that satisfies the division algorithm in regard to both quotient and remainder. In this procedure, division is performed… Expand

Special Cases of Division

- Computer Science
- J. Univers. Comput. Sci.
- 1995

This surveys algorithms and circuits for integer division in special cases. These include division by constants, small divisors, exact divisors, and cases where the divisor and the number base have a… Expand

IBM POWER8 processor core microarchitecture

- Computer Science
- IBM J. Res. Dev.
- 2015

The core microarchitecture innovations made in the POWER8 processor, designed to significantly improve both single-thread performance and single-core throughput over its predecessor, the POWER7® processor, are described. Expand

Hacker's Delight

- Computer Science
- 2002

The term "hacker" in the title is meant in the originalsense of an aficionado of computerssomeone who enjoys making computers do new things, or do old things in a new and clever way. Expand