abs - compute the absolute value of the argument
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(import (rnrs arithmetic flonums)) ;R6RS
SYNOPSIS
(abs number)
(flabs number)
DESCRIPTION
Returns the absolute value of
number.
This is only defined for real numbers.
RETURN VALUES
Returns a single value; a number. The flonum variant always returns a flonum.
EXAMPLES
(abs -47) => 47
(flabs -0.0) => 0.0
(abs -inf.0) => +inf.0
COMPATIBILITY
Except for differences in error handling and which types of numbers
are supported, these procedures work the same everywhere.
ERRORS
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.
In particular,
number
must be a real number and for the flonum variant it must be a flonum.
- R7RS
-
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.
SEE ALSO
magnitude(3scm)
STANDARDS
R4RS,
IEEE Scheme,
R5RS,
R6RS,
R7RS
HISTORY
In R2RS and R3RS the
abs
procedure accepted a complex number and returned its magnitude.
Scheme earlier than R2RS, running on MacLISP, had access to the
abs
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.
AUTHORS
This page is part of the
scheme-manpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.