(r5rs.info.gz) Numerical types
Info Catalog
(r5rs.info.gz) Numbers
(r5rs.info.gz) Numbers
(r5rs.info.gz) Exactness
6.2.1 Numerical types
---------------------
Mathematically, numbers may be arranged into a tower of subtypes in
which each level is a subset of the level above it:
number
complex
real
rational
integer
For example, 3 is an integer. Therefore 3 is also a rational, a real,
and a complex. The same is true of the Scheme numbers that model 3.
For Scheme numbers, these types are defined by the predicates
`number?', `complex?', `real?', `rational?', and `integer?'.
There is no simple relationship between a number's type and its
representation inside a computer. Although most implementations of
Scheme will offer at least two different representations of 3, these
different representations denote the same integer.
Scheme's numerical operations treat numbers as abstract data, as
independent of their representation as possible. Although an
implementation of Scheme may use fixnum, flonum, and perhaps other
representations for numbers, this should not be apparent to a casual
programmer writing simple programs.
It is necessary, however, to distinguish between numbers that are
represented exactly and those that may not be. For example, indexes
into data structures must be known exactly, as must some polynomial
coefficients in a symbolic algebra system. On the other hand, the
results of measurements are inherently inexact, and irrational numbers
may be approximated by rational and therefore inexact approximations.
In order to catch uses of inexact numbers where exact numbers are
required, Scheme explicitly distinguishes exact from inexact numbers.
This distinction is orthogonal to the dimension of type.
Info Catalog
(r5rs.info.gz) Numbers
(r5rs.info.gz) Numbers
(r5rs.info.gz) Exactness
automatically generated byinfo2html