The Euclidean definition of the functions div and mod
- 1 April 1992
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Programming Languages and Systems
- Vol. 14 (2) , 127-144
- https://doi.org/10.1145/128861.128862
Abstract
The definitions of the functions div and mod in the computer science literature and in programming languages are either similar to the Algol of Pascal definition (which is shown to be an unfortunate choice) or based on division by truncation (T-definition) or division by flooring as defined by Knuth (F-definition). The differences between various definitions that are in common usage are discussed, and an additional one is proposed, which is based on Euclid's theorem and therefore is called the Euclidean definition (E-definition). Its distinguishing feature is that 0 ≤ D mod d < | d | irrespective of the signs of D and d . It is argued that the E- and F-definitions are superior to all other ones in regularity and useful mathematical properties and hence deserve serious consideration as the standard convention at the applications and language level. It is also shown that these definitions are the most suitable ones for describing number representation systems and the realization of arithmetic operations at the architecture and hardware level.Keywords
This publication has 8 references indexed in Scilit:
- Multiplexed buses: the endian wars continueIEEE Micro, 1990
- Syntactic and semantic aspects of formal system descriptionMicroprocessing and Microprogramming, 1989
- Representational and denotational semantics of digital systemsIEEE Transactions on Computers, 1989
- On The Equivalence of Time-Division and Frequency-Division MultiplexingIEEE Transactions on Communications, 1985
- Pascal User Manual and ReportPublished by Springer Nature ,1985
- On Holy Wars and a Plea for PeaceComputer, 1981
- Arithmetic shifting considered harmfulACM SIGPLAN Notices, 1977
- Revised Report on the Algorithmic Language Algol 68Published by Springer Nature ,1976