[R6RS] proposing ten procedures
William D Clinger
will at ccs.neu.edu
Wed Jul 12 16:09:14 EDT 2006
(In our telephone conference, I mentioned 14 procedures
I was going to propose. Here they are, but there are
only 10. I miscounted, thinking there would be separate
procedures for each endianness.)
The following procedures are needed for support of
binary i/o and as primitives for implementing arrays
of inexact reals.
Will
--------
real->single x
real->double x
Given a real number x, these procedures compute the
best IEEE-754 single or double precision approximation
to x and return that approximation as an inexact real.
Note: Both of the two conversions performed by these
procedures (to IEEE-754 single or double, and then to
an inexact real) may lose precision, introduce error,
or may underflow or overflow.
Rationale: The ability to round to IEEE-754 single or
double precision is occasionally needed for control of
precision or for interoperability.
Issues: The argument could be limited to inexact reals
or to flonums. The result could be limited to flonums,
but that would be a problem for systems that use single
precision flonums but also support double precision.
bytes-ieee-single-native-ref bytes k
bytes-ieee-single-ref bytes k endianness
Returns the inexact real that best represents the
IEEE-754 single precision number represented by the
4 bytes beginning at index k.
An exception is raised if any of k through k+3 is not
a valid index. For bytes-ieee-single-native-ref, an
exception is raised if k is not a multiple of 4. For
bytes-ieee-single-ref, an exception is raised if
endianness is not one of the symbols big or little.
For unsafe mode, of course, these exceptions might
not be raised; all bets are off.
bytes-ieee-double-native-ref bytes k
bytes-ieee-double-ref bytes k endianness
Returns the inexact real that best represents the
IEEE-754 single precision number represented by the
8 bytes beginning at index k.
An exception is raised if any of k through k+7 is not
a valid index. For bytes-ieee-double-native-ref, an
exception is raised if k is not a multiple of 8. For
bytes-ieee-double-ref, an exception is raised if
endianness is not one of the symbols big or little.
For unsafe mode, of course, these exceptions might
not be raised; all bets are off.
bytes-ieee-single-native-set! bytes k x
bytes-ieee-single-set! bytes k x endianness
Stores an IEEE-754 single precision representation
of x into elements k through k+3 of bytes, and returns
the unspecified value.
An exception is raised if any of k through k+3 is not
a valid index. For bytes-ieee-single-native-set!, an
exception is raised if k is not a multiple of 4. For
bytes-ieee-double-set!, an exception is raised if
endianness is not one of the symbols big or little.
An exception is raised if x is not a real number.
For unsafe mode, of course, these exceptions might
not be raised; all bets are off.
bytes-ieee-double-native-set! bytes k x
bytes-ieee-double-set! bytes k x endianness
Stores an IEEE-754 single precision representation
of x into elements k through k+7 of bytes, and returns
the unspecified value.
An exception is raised if any of k through k+7 is not
a valid index. For bytes-ieee-double-native-set!, an
exception is raised if k is not a multiple of 8. For
bytes-ieee-double-set!, an exception is raised if
endianness is not one of the symbols big or little.
An exception is raised if x is not a real number.
For unsafe mode, of course, these exceptions might
not be raised; all bets are off.
[end of proposed procedures]
More information about the R6RS
mailing list