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
These procedures return the numerator or denominator of their
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
(numerator (/ 6 4)) => 3
(denominator (/ 6 4)) => 2
(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.
must be a rational number and
must be a flonum object.
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.
These procedures first appeared in R3RS.
The flonum variants are new to R6RS's flonum library.
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.