Next Previous Up Top Contents Index

5 Integers

5.1 Introduction

This chapter describes the Common Dylan implementation of arithmetic functions, especially integer arithmetic. It describes a number of extensions to the Dylan language, which are available from the Dylan library. It also describes a generic arithmetic facility that, through the use of other libraries, allows you to extend arithmetic to special number types, such as "big" (64-bit) integers.

Throughout this chapter, arguments are instances of the class specified by the argument name (ignoring any numeric suffixes), unless otherwise noted. Thus, the arguments integer, integer1, and integer2 would all be instances of the class <integer>.

The goals of the extensions to the Dylan language described in this chapter are as follows:

This allows type inference to propagate small integer declarations more widely, because there is no possibility of automatic coercion into some more general format.
Note: Using that library in another library does not have a negative effect on the correctness or performance of other libraries in the same application that do not use it.
In particular, the extensions support the production of efficient code for programs written to be portable with respect to the DRM specification. Use of implementation-specific types or operations in order to get reasonable efficiency is not required. This precludes relegating the <integer> class and limited-<integer> types to inefficient implementations.
Note: When there are several distinct interfaces with the same name but in different modules, the notation interface#module is used in this chapter to remove ambiguity.
The representation for integers must be at least 28 bits, including the sign. That is, the minimum conforming value for $maximum-integer is 227-1 and the maximum conforming value for $minimum-integer is -227.
Rationale: Restricting <integer> in this way allows the programmer to stay in the efficient range without requiring exact knowledge of what that range might be. The full generality of extended precision integers is provided by the Big-Integers library, for programmers who actually need that functionality.

The Dylan library provides implementations of the generic functions and functions described in this chapter. If the result of one of these operations is specified to be an instance of <integer> and the mathematically correct result cannot be represented as an <integer> then an error is signaled. This removes fully generic arithmetic from the Dylan library. In particular, it removes extended integers, ratios, and rectangular complex numbers.


Common Dylan and Functional Extensions - 31 Mar 00

Next Previous Up Top Contents Index