exact, inexact  conversion between exact and inexact numbers
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme base)) ;R7RS
; R5RS legacy names
(import (rnrs r5rs)) ;R6RS
(import (scheme r5rs)) ;R7RS
SYNOPSIS
(exact z)
(inexact z)
; R5RS legacy names
(inexact>exact z)
(exact>inexact z)
DESCRIPTION
The
exact
procedure returns an exact representation of
z.
The value returned is the exact number object that is numerically
closest to the argument; in most cases, the result of this procedure
should be numerically equal to its argument.
The
inexact
procedure returns an inexact representation of
z.
If inexact number objects of the appropriate type have bounded precision,
then the value returned is an inexact number object that is nearest to
the argument.
 Large numbers

For a real number object whose magnitude is finite but
so large that it has no reasonable finite approximation as an inexact
number, a reasonably close inexact equivalent may be
+inf.0
or
inf.0.
Similarly, the inexact representation of a complex number object whose
components are finite may have infinite components.
 Idempotency

The
inexact
and
exact
procedures are idempotent. This means that if they are called with a
number that already has the desired exactness, then they return that
number.
 Complex numbers (R7RS)

For complex numbers that do not already have the desired exactness,
the result is a complex number whose real and imaginary parts are the
result of applying the procedure to the real and imaginary parts of
the argument, respectively.
RETURN VALUES
Returns a single exact or inexact number object, respectively.
EXAMPLES
(exact 0.5)
=> 1/2
(inexact 3/4)
=> 0.75
APPLICATION USAGE
These procedures are used to manage the exactness used in computations.
COMPATIBILITY
R7RS implementations are not required to support the full numeric
tower.
ERRORS
These 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.
 &implementationrestriction (R6RS)

May be raised if an inexact argument has no reasonably close exact
equivalent, or an exact argument has no reasonably close inexact
equivalent, respectively.
 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.
An implementation restriction may be reported under the circumstances
described above for
&implementationrestriction,
indicating that the implementation is unable to continue execution of
a correct program. It may also be reported by the
exact
procedure when its argument is an inexact nonintegral real.
SEE ALSO
fixnum>flonum(3scm).
STANDARDS
R4RS,
IEEE Scheme,
R5RS,
R6RS,
R7RS
HISTORY
These procedures were called
exact>inexact
and
inexact>exact
in R5RS and earlier reports.
AUTHORS
This page is part of the
schememanpages
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.