THE EUCLIDEAN DEFINITION OF THE FUNCTIONS DIV AND MOD

被引:23
作者
BOUTE, RT
机构
[1] Department of Computer Science, University of Nijmegen, NL 6525 ED Nijmegen
来源
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS | 1992年 / 14卷 / 02期
关键词
DECIMATION; DIV FUNCTION; EUCLID THEOREM; HARDWARE DESCRIPTION; INTEGER DIVISION; INTERPOLATION; MOD FUNCTION; NUMBER REPRESENTATION; PREDEFINED FUNCTIONS; REMAINDER; RESIDUE; SAMPLING;
D O I
10.1145/128861.128862
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
The definitions of the functions div and mod in the computer science literature and in programming languages are either similar to the Algol or 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 less-than-or-equal-to 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.
引用
收藏
页码:127 / 144
页数:18
相关论文
共 20 条