Dylan provides a variety of numeric classes. Classes under <complex> are sealed, so that numeric operations on them can be highly optimized. User defined numeric classes will be subclasses of <number>.
Figure 11-3 shows the built-in number classes and some of their characteristics.
Figure 11-3 The Number Classes
| S | – Sealed | P | – Primary | C | – Concrete | I | – Instantiable |
| O | – Open | F | – Free | A | – Abstract | U | – Uninstantiable |
<number> [Open Abstract Class]The class of all numbers.
<object>
None.
None.
The class of all numbers.
The class <number> is open, to allow programmers to create additional numeric classes. The built-in numeric operations do not provide default implementations for <number>, but for <complex>, a sealed subclass of <number>.
<complex> [Sealed Abstract Class]The class of complex numbers.
<number>
None.
The sealed superclass of all built-in numbers, including real numbers. There are no non-real subclasses of <complex> defined by the language, but implementations may define such subclasses. Because <complex> and all its defined subclasses are sealed, implementation-defined subclasses may be added efficiently.
Many built-in functions are defined to have methods on <complex>. This means that the function is defined on all built-in subclasses of <complex>. It does not imply that there is a single method specialized on the <complex> class.
The class <complex> provides implementations for the following functions:
Function |
| Description | Page |
|---|---|---|---|
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
|
<real> [Sealed Abstract Class]The class of real numbers.
<complex>
None.
The class of real numbers.
The class <real> provides implementations for the following functions:
Function |
| Description | Page |
|---|---|---|---|
|
| ||
|
| ||
|
| Rounds a real number toward the nearest mathematical integer. | |
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
|
Function |
| Description | Page |
|---|---|---|---|
|
| Returns true if its first operand is less than its second operand. | |
|
| ||
|
| ||
|
| ||
|
| ||
|
|
The classes <single-float> and <double-float> are intended but not required to be the corresponding IEEE types. The class <extended-float> is intended but not required to have more range and/or precision than <double-float>.
If an implementation has fewer than three floating point classes, the names <single-float>, <double-float> and <extended-float> may all refer to the same object.
<float> [Sealed Abstract Class]The class of floating-point numbers.
<real>
None.
The class of all floating-point numbers. This class is abstract. All floating point numbers will be instances of some concrete subclass of this class.
None.
<single-float> [Sealed Class]The class of single-precision floating-point numbers.
<float>
None.
The class of single-precision floating-point numbers. This class is intended but not required to correspond to IEEE single-precision.
None.
<double-float> [Sealed Class]The class of double-precision floating-point numbers.
<float>
None.
The class of double-precision floating-point numbers. This class is intended but not required to correspond to IEEE double-precision.
None.
<extended-float> [Sealed Class]The class of extended-precision floating-point numbers.
<float>
None.
The class of extended-precision floating-point numbers. This class is intended but not required to provide more precision that <double-float>.
None.
<rational> [Sealed Abstract Class]The class of rational numbers.
<real>
None.
The class of rational numbers.
None.
<integer> [Sealed Class]The class of integers.
<rational>
None.
The class of integers.
Implementations are required to support integers with at least 28 bits of precision. The overflow and underflow behavior is implementation-defined. (Some implementations may choose to have integers of unlimited size, but this is not required.)
The result of dividing two integers with / is implementation defined. Portable programs should use floor/, ceiling/, round/, or truncate/ to divide two integers.
The class <integer> provides the following operations:
Function |
| Description | Page |
|---|---|---|---|
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| Tests the value of a particular bit in its integer argument. | |
|
|
Function |
| Description | Page |
|---|---|---|---|
|
| ||
|
|
Function |
| Description | Page |
|---|---|---|---|
|
|