abs - compute the absolute value of the argument
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(import (rnrs arithmetic flonums)) ;R6RS
Returns the absolute value of
This is only defined for real numbers.
Returns a single value; a number. The flonum variant always returns a flonum.
(abs -47) => 47
(flabs -0.0) => 0.0
(abs -inf.0) => +inf.0
Except for differences in error handling and which types of numbers
are supported, these procedures work the same everywhere.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
must be a real number and for the flonum variant it must be a flonum.
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
In R2RS and R3RS the
procedure accepted a complex number and returned its magnitude.
Scheme earlier than R2RS, running on MacLISP, had access to the
subroutine that accepted a real number. LISP 1.5 does not seem to have
had this function but an example definition is given as an
M-expression in the LISP 1.5 Programmer's Manual.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.