[r6rs-discuss] flonum operations?

From: Aubrey Jaffer <agj>
Date: Wed Sep 20 12:20:48 2006

 | Date: Mon, 18 Sep 2006 21:46:02 -0400
 | From: "Peter Gavin" <pgavin_at_gmail.com>
 |
 | Why doesn't the report include procedures like flonum-mantissa,
 | flonum-exponent, flonum-sign, etc. that return the mantissa,
 | exponent, and sign, etc.? The implementation should already be able
 | to determine the mantissa width (at least for denormalized numbers,
 | see section 3.2.7, page 14, second column). These are all pretty
 | trivial operations, especially if the implementation's flonums are
 | IEEE doubles.

There are many uses for fixed-size portable numeric representations,
for instance database keys and values.

And this can be done without resorting to native data format
conversions. The SLIB Byte/Number Conversions package
(http://cvs.savannah.gnu.org/viewcvs/slib/slib/bytenumb.scm?view=markup)
converts between bytes and IEEE flonums using only R4RS Scheme. It
recognizes only one NaN, but otherwise handles all IEEE single and
double floats (including -0).

When using numbers for database keys, byte order is important. With
bigendian IEEE floats, positive numbers precede negative numbers. The
SLIB package also has conversion routines which provide correct
collation order for flonums (and integers).
Received on Wed Sep 20 2006 - 12:20:23 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC