Next Previous Up Top Contents Index

5.2 Extensions to the Dylan library

5.2.6 Arithmetic operations

The following arithmetic operations are available in the Dylan library:

+

Open generic function

+ object1 object2 => #rest object 

+

Sealed domain

+ complex1 complex2 

+

G.f. method

+ integer1 integer2 => integer 

+

G.f. method

+ machine-number1 machine-number2 => machine-number 

Returns the sum of the two supplied arguments. The actual type of the value is determined by the contagion rules when applied to the arguments.
-

Open generic function

- object1 object2 => #rest object 

-

Sealed domain

- complex1 complex2 

-

G.f. method

- integer1 integer2 => integer 

-

G.f. method

- machine-number1 machine-number2 => machine-number 

Returns the result of subtracting the second argument from the first. The actual type of the value is determined by the contagion rules when applied to the arguments.
*

Open generic function

* object1 object2 => #rest object 

*

Sealed domain

* complex1 complex2 

*

G.f. method

* integer1 integer2 => integer 

*

G.f. method

* machine-number1 machine-number2 => machine-number 

Returns the result of multiplying the two arguments. The actual type of the value is determined by the contagion rules when applied to the arguments.
/

Open generic function

/ object1 object2 => #rest object 

/

Sealed domain

/ complex1 complex2 

/

G.f. method

/ float1 float2 => float 

Returns the result of dividing the first argument by the second. The actual type of the value is determined by the contagion rules when applied to the arguments.
negative

Open generic function

negative object => #rest negative-object 

negative

Sealed domain

negative complex 

negative

G.f. method

negative integer => negative-integer 

negative

G.f. method

negative float => negative-float 

Negates the supplied argument. The returned value is of the same float format as the supplied argument.
floor

Function

floor machine-number => integer machine-number 
floor integer => integer integer
floor float => integer float

Truncates a number toward negative infinity. The integer part is returned as integer, the remainder is of the same float format as the argument.
ceiling

Function

ceiling machine-number => integer machine-number 
ceiling integer => integer integer
ceiling float => integer float

Truncates a number toward positive infinity. The integer part is returned as integer, the remainder is of the same float format as the argument.
round

Function

round machine-number => integer machine-number 
round integer => integer integer
round float => integer float

Rounds a number toward the nearest mathematical integer. The integer part is returned as integer, the remainder is of the same float format as the argument. If the argument is exactly between two integers, then the result integer will be a multiple of two.
truncate

Function

truncate machine-number => integer machine-number
truncate integer => integer integer
truncate float => integer float

Truncates a number toward zero. The integer part is returned as integer, the remainder is of the same float format as the argument.
floor/

Function

floor/ machine-number1 machine-number2 => integer machine-number
floor/ integer1 integer2 => integer integer
floor/ machine-number1 machine-number2 => integer machine-number

Divides the first argument into the second and truncates the result toward negative infinity. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
ceiling/

Function

ceiling/ machine-number1 machine-number2 => integer machine-number
ceiling/ integer1 integer2 => integer integer
ceiling/ machine-number1 machine-number2 => integer machine-number

Divides the first argument into the second and truncates the result toward positive infinity. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
round/

Function

round/ machine-number1 machine-number2 => integer machine-number
round/ integer1 integer2 => integer integer
round/ machine-number1 machine-number2 => integer machine-number

Divides the first argument into the second and rounds the result toward the nearest mathematical integer. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
truncate/

Function

truncate/ machine-number1 machine-number2 => integer machine-number
truncate/ integer1 integer2 => integer integer
truncate/ machine-number1 machine-number2 => integer machine-number

Divides the first argument into the second and truncates the result toward zero. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
modulo

Function

modulo machine-number1 machine-number2 => machine-number
modulo integer1 integer2 => integer
modulo machine-number1 machine-number2 => machine-number
Returns the second value of floor/ (arg1, arg2). The actual type of the second value is determined by the contagion rules when applied to the arguments.
remainder

Function

remainder machine-number1 machine-number2 => machine-number
remainder integer1 integer2 => integer 
remainder machine-number1 machine-number2 => machine-number
Returns the second value of truncate/ (arg1, arg2).The actual type of the second value is determined by the contagion rules when applied to the arguments.
^

Open generic function

^ object1 object2 => #rest object 

^

Sealed domain

^ complex1 complex2 

^

G.f. method

^ integer1 integer2 => integer 

^

G.f. method

^ float1 integer2 => float 

Returns the first argument raised to the power of the second argument. The value is of the same float format as the first argument. An error is signalled if both arguments are 0.
abs

Open generic function

abs object => #rest object 

abs

Sealed domain

abs complex 

abs

G.f. method

abs integer => integer 

abs

G.f. method

abs float => float 

Returns the absolute value of the argument. The value is of the same float format as the argument.
logior

Function

logior #rest integers => integer 

Returns the bitwise inclusive OR of its integer arguments.
logxor

Function

logxor #rest integers => integer

Returns the bitwise exclusive OR of its integer arguments.
logand

Function

logand #rest integers => integer 

Returns the bitwise AND of its integer arguments.
lognot

Function

lognot integer1 => integer2

Returns the bitwise NOT of its integer arguments.
logbit?

Function

logbit? index integer => boolean

Tests the value of a particular bit in its integer argument. The index argument is an instance of <integer>.
ash

Function

ash integer1 count => integer 

Performs an arithmetic shift on its first argument.
lcm

Function

lcm integer1 integer2 => integer

Returns the least common multiple of its two arguments.
gcd

Function

gcd integer1 integer2 => integer

Returns the greatest common divisor of its two arguments.

Common Dylan and Functional Extensions - 31 Mar 00

Next Previous Up Top Contents Index