numerator, denominator, flnumerator, fldenominator - compute numerator and
denominator
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(import (rnrs arithmetic flonums)) ;R6RS
(denominator q)
(numerator q)
(fldenominator fl)
(flnumerator fl)
These procedures return the numerator or denominator of their argument.
The result is computed as if the argument was represented as a
fraction in lowest terms. The denominator is always positive. The
denominator of 0 is defined to be 1.
Returns a single value; an integer with the same exactness as the argument.
(numerator (/ 6 4)) => 3
(denominator (/ 6 4)) => 2
(denominator
(inexact (/ 6 4))) => 2.0
(numerator 5) => 5
(denominator 5) => 1
These procedures, or their equivalents, are used internally in many arithmetic
procedures. Since they must exist somewhere in the implementation it makes
sense to provide them to the user.
These procedures work the same everywhere, except that R7RS implementations are
allowed to not support all types of numbers.
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, q must be a rational number and fl
must be a flonum object.
- 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.
R4RS, IEEE Scheme, R5RS, R6RS, R7RS
These procedures first appeared in R3RS. The flonum variants are new to R6RS's
flonum library.