| Date: Fri, 29 Jun 2007 10:24:28 -0500
| From: Alan Watson <alan at alan-watson.org>
|
| Here is the problem I want to solve. I want to be able to read IEEE
| singles and doubles and have them represented by the nearest
| inexact real. I want to be able to write the IEEE single and double
| that is nearest to a given inexact real. I am prepared to accept a
| solution that works on many but not all implementations and I am
| prepared to do some of the work myself.
|
| I can see a number of solutions. First, the input problem:
|
| (b) Throw out |p and return to the R5RS syntax for inexact numbers.
| Actually, we're a bit better than the R5RS, as I can generate IEEE
| single-precision and double-precision values using byte vectors
| literals and procedures. Someone smarter than I might be able to
| wrap this in a nice macro, which would work well for programs. Data
| will be a bit messy, as I will have to process it an convert byte
| vectors to inexacts as appropriate.
|
| ...
|
| Now the output problem. First, we should accept that inexact
| arithmetic is ... inexact. Therefore we do the best we can:
|
| (b) We throw out |p and the third argument to number->string. I
| will have to write IEEE singles and doubles using byte vectors,
| which won't work so well for data but I can live with that.
SLIB provides IEEE single and double number-byte conversions:
http://swiss.csail.mit.edu/~jaffer/slib_7.html#SEC189
Received on Sun Jul 01 2007 - 14:22:33 UTC