Numeric Procedures

Numeric procedures cover exact arithmetic, mixed finite-real arithmetic, exact comparison, integer division families, rounding, gcd/lcm, integer exponentiation, and exact integer square root.

See it run

LISPEX
(call-with-values (lambda () (exact-integer-sqrt 20)) list)

Observed result

OUTPUT
(4 4)

How to reason about it

  • + - * / are variadic as specified; comparisons require at least two arguments; integer-domain operations reject non-integers.
  • floor/ and truncate/ return quotient and remainder as two values.
  • expt accepts an exact-integer exponent; exact-integer-sqrt returns root and remainder.

Numeric signatures

SignatureResultFault boundary
(+ number ...) / (* number ...)number; exact unless any operand is inexactE312 wrong type; E314 non-finite
(/ number number ...)exact rational or finite realE313 zero divisor; E314 non-finite
(floor/ integer integer)two values: quotient, remainderE312 non-integer; E313 zero divisor
(expt number exact-integer)number preserving base exactnessE313 exact zero to negative; E314 unrepresentable
(exact-integer-sqrt exact-nonnegative-integer)two exact values: root, remainderE312 wrong domain

A common mistake

General transcendental functions and non-finite values are absent.

Keep going

Use this page while writing code. For a guided explanation, return to the syntax map or the corresponding manual.

Syntax at a Glance · Learning Path