Re: [Scheme-reports] EQV? on numbers should be based on operational equivalence
Aubrey Jaffer 09 May 2012 17:06 UTC
| Date: Wed, 9 May 2012 00:03:05 -0400
| From: John Cowan <cowan@mercury.ccil.org>
|
| Ray Dillinger scripsit:
|
| > A high-level language such as scheme ought to treat values as
| > values according to their types, not as bit layouts. Control
| > over bit layouts should be purely for external purposes;
| > reading/writing binary formats and interfacing with ABI's.
|
| Well then, either binary files and FFIs cannot be standardized, or
| we have to admit that there are boundaries to "operational
| equivalence". I go with the latter viewpoint.
The SLIB byte-number module (using byte and logical modules)
<http://cvs.savannah.gnu.org/viewvc/*checkout*/slib/slib/bytenumb.scm>
converts (both directions) between byte-vectors and IEEE
floating-point numbers using only R4RS arithmetic procedures. It can
produce either endianness; default is big-endian. The endianess it
uses is completely independent of the native CPU endianess.
Because it cannot "see" bits within NaN, it uses a single bit-pattern
for the byte-vector representation of NaN. A NaN converted from a
byte-vector uses whichever NaN results from dividing 0.0 by 0.0 on the
host CPU.
Access to hardware representations of numbers is not needed for
portably "reading/writing binary formats". The SLIB "pnm" module
(using other modules) can read and write binary pbm, pgm, and ppm
files using only R4RS.
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports