Abstract

AbstractComputers are finite machines and, therefore, the arithmetic operations in a programming language are different from their mathematical counterparts. These restrictions seem not to have been, in general, fully appreciated in programming languages and in computer science textbooks. One example is the programming language Java, which makes it difficult to warn the user in cases in which arithmetic operations produce incorrect results. In this paper we look at integer arithmetic in Java and develop a safe variant of the arithmetic operations in Java. The design of the safe variant of $+$, $-_{\rm un}$, $-_{\rm bin}$, $*$, $/$ and $**$ for the types byte, short, int and long reveals a number of deficiencies of Java in integer arithmetic, floating point arithmetic and program structure. Some of these deficiencies are also present in other contemporary programming languages. The paper therefore ends with some proposals for the design of the arithmetic elements of programming languages. Copyright © 2002 John Wiley & Sons, Ltd.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call