Dylan supports several kinds of numerical representations. The classes for these representations are placed in a hierarchy of abstract classes corresponding to mathematical number types. The abstract classes have no direct instances but are useful for specialization. The complete class hierarchy is shown below. Abstract classes are shown in italics. Sealed classes are shown in bold.

The <single-float>, <double-float>, and <extended-float> classes implement the IEEE standard floating-point formats FN34 .

<number>[Abstract Class]<real>[Abstract Class]<float>[Instantiable Class]<single-float>[Instantiable Class]<double-float>[Instantiable Class]<extended-float>[Instantiable Class]<rational>[Instantiable Class]<ratio>[Instantiable Class]<integer>[Instantiable Class]<complex>[Instantiable Class]

**Complex Numbers**

**
**The class <complex> accepts the init-keywords real:, imag:, magnitude:, and angle:. The arguments are interpreted as follows:

*none*- (make-rectangular 0 0)
- real:
*r* - (make-rectangular
*r*0) - imag:
*i* - (make-rectangular 0
*i*) - real:
*r*imag:*i* - (make-rectangular
*r**i*) - magnitude:
*m* - (make-polar
*m*0) - angle:
*a* - (make-polar 0
*a*) - magnitude:
*m*angle:*a* - (make-polar
*m**a*)

**make-rectangular***real-part imag-part*=>*complex*- [Generic Function]

These functions are used to create complex numbers.

These functions test a number for the given property and return a Boolean result.odd?integer=>boolean[Generic Function]even?integer=>boolean[Generic Function]zero?number=>boolean[Generic Function]positive?real=>boolean[Generic Function]negative?real=>boolean[Generic Function]integral?number=>boolean[Generic Function]

**Arithmetic Operations**

**See Also: Dylan Design Notes: Variadic Operators (Change)**

**See Also:Dylan Design Notes: Divide By Zero Signals Error (Clarifiaction)**

These methods return the sum or product of their arguments. With no arguments, + returns the <integer> 0 and * returns the <integer> 1. With one argument, both return the argument. With two or more arguments, they combine the arguments in pairs by calling binary+ or binary*.+#restnumbers=>number[Method]*#restnumbers=>number[Method]

+ and * are methods, so you cannot add other methods to them. To extend the protocol, define methods on binary+ and binary*.

With one argument, returns the additive inverse of the argument and / returns the multiplicative inverse of the argument. With two or more arguments, they combine the arguments in pairs by calling binary- or binary/.-number#restnumbers=>number[Method]/number#restnumbers=>number[Method]

and / are methods, so you cannot add other methods to them. To extend the protocol, define methods on binary-, binary/, unary-, and unary/.

Called by +, *, , and /. Programs should not call these functions directly.binary+number1number2=>number[Generic Function]binary*number1number2=>number[Generic Function]binary/number1number2=>number[Generic Function]binary-number1number2=>number[Generic Function]unary-number=>number[Generic Function]unary/number=>number[Generic Function]

These functions return the sum, product, difference, quotient, additive inverse, and multiplicative inverse of their arguments, respectively.

These functions are equivalent to the one-argument forms of the like-named Common Lisp (X3J13) functions.floorreal=>integer real[Generic Function]ceilingreal=>integer real[Generic Function]round;real=>integer real[Generic Function]truncate;real=>integer real[Generic Function]

These functions are equivalent to the two-argument forms of floor, ceiling, round, and truncate in Common Lisp (X3J13).floor/real1 real2=>integer real[Generic Function]ceiling/real1 real2>integer real[Generic Function]round/real1 real2> integer real[Generic Function]truncate/;real1 real2=>integer real[Generic Function]

modulo returns the second value of (floor/moduloreal1 real2=>real[Generic Function]

remainder returns the second value of (truncate/remainderreal1 real2=>real[Generic Function]

**See Also: Dylan Design Notes: Remove Transcendental Functions (Change)**

**See Also: Dylan Design Notes: Remove Trivial Logical Operators (Change)**

The generic functions abs, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, exp, log, expt, sqrt, logior, logxor, logand, logeqv, lognand, lognor, logandc1, logandc2, logorc1, logorc2, lognot, ash are as defined in Common Lisp. atan2 is equivalent to the two-argument version of atan; logbit? is equivalent to Common Lisps logbitp.absnumber=>number[Generic Function]sinnumber=>number[Generic Function]cosnumber=>number[Generic Function]tannumber=>number[Generic Function]asinnumber=>number[Generic Function]acosnumber=>number[Generic Function]atannumber=>number[Generic Function]atan2number1 number2=>number[Generic Function]sinhnumber=>number[Generic Function]coshnumber=>number[Generic Function]tanhnumber=>number[Generic Function]asinhnumber=>number[Generic Function]acoshnumber=>number[Generic Function]atanhnumber=>number[Generic Function]expnumber=>number[Generic Function]lognumber=>number[Generic Function]exptnumber1 number2=>number[Generic Function]sqrtnumber=>number[Generic Function]logior#restintegers=>integer[Generic Function]logxor#restintegers=>integer[Generic Function]logand#restintegers=>integer[Generic Function]logeqv#restintegers=>integer[Generic Function]lognandinteger1 integer2=>integer[Generic Function]lognorinteger1 integer2=>integer[Generic Function]logandc1integer1 integer2=>integer[Generic Function]logandc2integer1 integer2=>integer[Generic Function]logorc1integer1 integer2=>integer[Generic Function]logorc2integer1 integer2=>integer[Generic Function]lognotinteger=>integer[Generic Function]logbitindex integer=>boolean[Generic Function]ashinteger count=>integer[Generic Function]

**See Also: Dylan Design Notes: Remove Transcendental Functions (Change)**

The generic functions rationalize, numerator, denominator, real-part, imag-part, and angle are as defined inrationalizenumber=>number[Generic Function]numeratornumber=>number[Generic Function]denominatornumber=>number[Generic Function]real-partnumber=>number[Generic Function]imag-partnumber=>number[Generic Function]anglenumber=>number[Generic Function]

**See Also: Dylan Design Notes: Variadic Operators (Change)**

With no arguments, lcm returns the <integer> 1 and gcd returns the <integer> 0. With one argument, both return the argument. With two or more arguments, they combine the arguments left to right, equivalent to calling(reduce binary-lcm 1lcm#restintegers=>integer[Method]gcd#restintegers=>integer[Method]

lcm and gcd are methods, so you cannot add other methods to them. To extend the protocol, define methods on binary-lcm and binary-gcd.

These functions return the least common multiple and greatest common divisor ofbinary-lcminteger1 integer2=>integer[Generic Function]binary-gcdinteger1 integer2=>integer[Generic Function]

min returns the argument that is least (closest to negative infinity). max returns the argument that is greatest (closest to positive infinity). The methods operate by calling binary<.minreal#restmore-reals=>real[Method]maxreal#restmore-reals=>real[Method]