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
+ number1 number2 => number [Generic Function] * number1 number2 => number [Generic Function] - number1 number2 => number [Generic Function] / number1 number2 => 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:
5 + 6 * 4Use the name of the function preceded by a backslash (\+, \*, \-, 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;
negative number => number [Generic Function]
This function returns the additive inverse of its argument. The unary minus operator is defined to call negative.
floor real => integer real [Generic Function] ceiling real => integer real [Generic Function] round real => integer real [Generic Function] truncate real => 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 of floor, ceiling, round, and truncate in Common Lisp (X3J13). Division by zero signals an error.
modulo real1 real2 => real [Generic Function]
modulo returns the second value of floor/ ( real1 , real2).
remainder real1 real2 => real [Generic Function]
remainder returns the second value of truncate/ ( real1 , real2).
number1 ^ integer2 => number [Generic Function]
Returns number1 raised to the power integer2.
abs number => number [Generic Function] logior #rest integers => integer [Generic Function] logxor #rest integers => integer [Generic Function] logand #rest integers => integer [Generic Function] lognot integer => integer [Generic Function] logbit? index integer => boolean [Generic Function] ash integer count => integer [Generic Function]
The generic functions abs, logior, logxor, logand, lognot, ash are as defined in Common Lisp. logbit? is equivalent to Common Lisp's logbitp.
rationalize number => number [Generic Function] numerator number => number [Generic Function] denominator number => number [Generic Function]
The generic functions rationalize, numerator, and denominator are as defined in Revised[4] Report on Scheme.
lcm integer1 integer2 => integer [Generic Function] gcd integer1 integer2 => integer [Generic Function]
These functions return the least common multiple and greatest common divisor of integer1 and integer2, respectively
min real #rest more-reals => real [Function] max real #rest more-reals => real [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 <.Next section: Functional Operations