Chapter 11
The BuiltIn Classes
Numbers
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 113 shows the builtin number classes and some of their characteristics.
Figure 113 The Number Classes
S  – Sealed  P  – Primary  C  – Concrete  I  – Instantiable 
O  – Open  F  – Free  A  – Abstract  U  – Uninstantiable 
Errata: In the published
book, <complex>
is incorrectly identified
as <complexnumber>
in Figure 113.
General Numbers
<number>
[Open Abstract Class]
The class of all numbers.
 Superclasses:
<object>
 Initkeywords:
None.
 Operations:
None.
 Description:

The class of all numbers.
The class
<number>
is open, to allow programmers to create additional numeric classes. The builtin numeric operations do not provide default implementations for<number>
, but for<complex>
, a sealed subclass of<number>
.
Complex Numbers
<complex>
[Sealed Abstract Class]
The class of complex numbers.
 Superclasses:
<number>
 Initkeywords:
None.
 Description:

The sealed superclass of all builtin numbers, including real numbers. There are no nonreal subclasses of
<complex>
defined by the language, but implementations may define such subclasses. Because<complex>
and all its defined subclasses are sealed, implementationdefined subclasses may be added efficiently.Many builtin functions are defined to have methods on
<complex>
. This means that the function is defined on all builtin subclasses of<complex>
. It does not imply that there is a single method specialized on the<complex>
class.  Operations:
The class <complex> provides implementations for the following functions:
Table 1110 Methods on <complex> Function
Description
Page
=
zero?
+
*

/
^
Reals
<real>
[Sealed Abstract Class]
The class of real numbers.
 Superclasses:
<complex>
 Initkeywords:
None.
 Description:
The class of real numbers.
 Operations:

The class
<real>
provides implementations for the following functions:Table 1111 Functions on <real> Function
Description
Page
floor
ceiling
round
Rounds a real number toward the nearest mathematical integer.
truncate
floor/
ceiling/
round/
truncate/
modulo
remainder
Table 1112 Methods on <real> Function
Description
Page
<
Returns true if its first operand is less than its second operand.
abs
positive?
negative?
integral?
negative
Floats
The classes <singlefloat>
and <doublefloat>
are intended but not required to be the corresponding
IEEE types. The class <extendedfloat>
is intended but not required to
have more range and/or precision than <doublefloat>
.
If an implementation has fewer than three floating point classes, the
names <singlefloat>
, <doublefloat>
and <extendedfloat>
may all refer to the same object.
<float>
[Sealed Abstract Class]
The class of floatingpoint numbers.
 Superclasses:
<real>
 Initkeywords:
None.
 Description:
The class of all floatingpoint numbers. This class is abstract. All floating point numbers will be instances of some concrete subclass of this class.
 Operations:
None.
<singlefloat>
[Sealed Class]
The class of singleprecision floatingpoint numbers.
 Superclasses:
<float>
 Initkeywords:
None.
 Description:
The class of singleprecision floatingpoint numbers. This class is intended but not required to correspond to IEEE singleprecision.
 Operations:
None.
<doublefloat>
[Sealed Class]
The class of doubleprecision floatingpoint numbers.
 Superclasses:
<float>
 Initkeywords:
None.
 Description:
The class of doubleprecision floatingpoint numbers. This class is intended but not required to correspond to IEEE doubleprecision.
 Operations:
None.
<extendedfloat>
[Sealed Class]
The class of extendedprecision floatingpoint numbers.
 Superclasses:
<float>
 Initkeywords:
None.
 Description:
The class of extendedprecision floatingpoint numbers. This class is intended but not required to provide more precision than
<doublefloat>
. Operations:
None.
Rationals
<rational>
[Sealed Abstract Class]
The class of rational numbers.
 Superclasses:
<real>
 Initkeywords:
None.
 Description:
The class of rational numbers.
 Operations:
None.
Integers
<integer>
[Sealed Class]
The class of integers.
 Superclasses:
<rational>
 Initkeywords:
None.
 Description:

The class of integers.
Implementations are required to support integers with at least 28 bits of precision. The overflow and underflow behavior is implementationdefined. (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/
, ortruncate/
to divide two integers.  Operations:

The class
<integer>
provides the following operations:Table 1113 Functions on <integer> Function
Description
Page
odd?
even?
logior
logxor
logand
lognot
logbit?
Tests the value of a particular bit in its integer argument.
ash
Table 1114 Methods on <integer> Function
Description
Page
lcm
gcd
Table 1115 Methods on singleton(<integer>) Function
Description
Page
limited