## General Arithmetic Functions

## Properties

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]

These functions test a number for the given property and return a Boolean result.## Arithmetic Operations

+number1number2=>number[Generic Function]*number1number2=>number[Generic Function]-number1number2=>number[Generic Function]/number1number2=>number[Generic Function]

These functions return the sum, product, difference, and quotient of their arguments, respectively. Division by zero signals an error.Use the name of the function (

+, *, -,or/) when you use the function in an infix expression:Use the name of the function preceded by a backslash (5 + 6 * 4\+, \*, \-,or\/) when you are using the function in any other way, such as adding new methods to it or passing it as a functional argument:define class <my-number> (<number>) end class; define method \+ (a :: <my-number>, b :: <my-number>) my-personal-addition-method(a, b); end method;

negativenumber=>number[Generic Function]

This function returns the additive inverse of its argument. The unary minus operator is defined to callnegative.

floorreal=>integer real[Generic Function]ceilingreal=>integer real[Generic Function]roundreal=>integer real[Generic Function]truncatereal=>integer real[Generic Function]

These functions are equivalent to the one-argument forms of the like-named Common Lisp (X3J13) functions.

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]

These functions are equivalent to the two-argument forms offloor,ceiling,round, andtruncatein Common Lisp (X3J13). Division by zero signals an error.

moduloreal1 real2=>real[Generic Function]

moduloreturns the second value offloor/ (real1,real2).

remainderreal1 real2=>real[Generic Function]

remainderreturns the second value oftruncate/ (real1,real2).

number1^integer2=>number[Generic Function]

Returnsnumber1raised to the powerinteger2.

absnumber=>number[Generic Function]logior#restintegers=>integer[Generic Function]logxor#restintegers=>integer[Generic Function]logand#restintegers=>integer[Generic Function]lognotinteger=>integer[Generic Function]logbit?index integer=>boolean[Generic Function]ashinteger count=>integer[Generic Function]

The generic functionsabs,logior,logxor,logand,lognot,ashare as defined in Common Lisp.logbit?is equivalent to Common Lisp'slogbitp.

rationalizenumber=>number[Generic Function]numeratornumber=>number[Generic Function]denominatornumber=>number[Generic Function]

The generic functionsrationalize,numerator, anddenominatorare as defined inRevised[4] Report on Scheme.

lcminteger1 integer2=>integer[Generic Function]gcdinteger1 integer2=>integer[Generic Function]

These functions return the least common multiple and greatest common divisor ofinteger1andinteger2, respectively

minreal#restmore-reals=>real[Function]maxreal#restmore-reals=>real[Function]

Next section: Functional Operationsminreturns the argument that is least (closest to negative infinity).maxreturns the argument that is greatest (closest to positive infinity). The methods operate by calling<.