[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

inexact numbers in R3.99RS

I want to point out and explain a few changes that were made in R3.99RS
that have to do with inexact numbers.  First of all, I added an explicit
note to the description of MAX and MIN.  Secondly, I relaxed the
specification of NUMBER->STRING to allow for implementations that
don't necessarily use floating point to represent inexact numbers.
Thirdly, I followed a suggestion made by the P1178 editors in making
part of the behavior of STRING->NUMBER optional to take into account
the fact that all numbers other than exact integers are optional.

Here are the relevant excerpts from the LaTeX for R3.99RS.  You don't
need to tell me about the place where I used "an" when I should have
used "a".

\proto{max}{ \vri{x} \vrii{x} \dotsfoo}{essential procedure}
\proto{min}{ \vri{x} \vrii{x} \dotsfoo}{essential procedure}}

These procedures return the maximum or minimum of their arguments.

(max 3 4)              \ev  4    ; exact
(max 3.9 4)            \ev  4.0  ; inexact%

If any argument is inexact, then the result will also be inexact (unless
the procedure can prove that the inaccuracy is not large enough to affect the
result, which is possible only in unusual implementations).  If \ide{min} or
\ide{max} is used to compare numbers of mixed exactness, and the numerical
value of the result cannot be represented as an inexact number without loss of
accuracy, then the procedure may report a violation of an implementation


\proto{number->string}{ number}{essential procedure}
\proto{number->string}{ number radix}{essential procedure}}

\vr{Radix} must be an exact integer, either 2, 8, 10, or 16.  If omitted,
\vr{radix} defaults to 10.
The procedure \ide{number\coerce{}string} takes a
number and a radix and returns as a string an external representation of
the given number in the given radix such that
(let ((number \vr{number})
      (radix \vr{radix}))
  (eqv? number
        (string->number (number->string number
is true.  It is an error if no possible result makes this expression true.

If \vr{number} is inexact, the radix is 10, and the above expression
can be satisfied by a result that contains a decimal point,
then the result contains a decimal point and is expressed using the
minimum number of digits (exclusive of exponent and trailing
zeroes) needed to make the above expression true~\cite{Heuristic};
otherwise the format of the result is unspecified.

The result returned by \ide{number\coerce{}string}
never contains an explicit radix prefix.

The error case can occur only when \vr{number} is not a complex number
or is a complex number with an non-rational real or imaginary part.

If \vr{number} is an inexact number represented using flonums, and
the radix is 10, then the above expression is normally satisfied by
a result containing a decimal point.  The unspecified case
allows for infinities, NaNs, and non-flonum representations.


\proto{string->number}{ string}{essential procedure}
\proto{string->number}{ string radix}{essential procedure}}

%%R4%% I didn't include the (string->number string radix exactness)
% case, since I haven't heard any resolution of the coding to be used
% for the third argument.

Returns a number of the maximally precise representation expressed by the
given \vr{string}.  \vr{Radix} must be an exact integer, either 2, 8, 10,
or 16.  If supplied, \vr{radix} is a default radix that may be overridden
by an explicit radix prefix in \vr{string} (e.g. {\tt "\#o177"}).  If \vr{radix}
is not supplied, then the default radix is 10.  If \vr{string} is not
a syntactically valid notation for a number, then \ide{string->number}
returns \schfalse{}.

(string->number "100")        \ev  100
(string->number "100" 16)     \ev  256
(string->number "1e2")        \ev  100.0
(string->number "15\#\#")       \ev  1500.0%

Although \ide{string->number} is an essential procedure,
an implementation may restrict its domain in the
following ways.  \ide{String->number} is permitted to return
\schfalse{} whenever \vr{string} contains an explicit radix prefix.
If all numbers supported by an implementation are real, then
\ide{string->number} is permitted to return \schfalse{} whenever
\vr{string} uses the polar or rectangular notations for complex
numbers.  If all numbers are integers, then
\ide{string->number} may return \schfalse{} whenever
the fractional notation is used.  If all numbers are exact, then
\ide{string->number} may return \schfalse{} whenever
an exponent marker or explicit exactness prefix is used, or if
a {\tt \#} appears in place of a digit.  If all inexact
numbers are integers, then
\ide{string->number} may return \schfalse{} whenever
a decimal point is used.