[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] IEEE float arithmetic
From: |
John Cowan |
Subject: |
[Chicken-users] IEEE float arithmetic |
Date: |
Mon, 19 Jun 2006 12:18:06 -0400 |
User-agent: |
Mutt/1.3.28i |
I'd like to have Chicken inexact numbers play nicely as IEEE floats,
since on all practical platforms they *are* IEEE floats. This involves
the following modifications.
1) Allow the reader to understand Infinity.0, -Infinity.0, and NaN.0 .
These should be defined in the reader as numeric literals. As a fallback,
they could be defined in Scheme code:
(define Infinity.0 (* 1.0e307 1.0e307))
(define -Infinity.0 (* -1.0e307 1.0e307))
(define NaN.0 (- Infinity.0 -Infinity.0))
This, however, makes them only available in code, not in a Scheme datum.
2) Remove the divide-by-zero trap in inexact division, and allow the IEEE
results to appear openly. This will mean that (/ 1.0 0.0) will evaluate
to Infinity.0, (/ -1.0 0.0) to -Infinity.0, and (/ 0.0 0.0) to NaN.0.
These literals are already produced by the Scheme printer. Alternatively,
both reader and printer could be changed to use the SRFI-77 (and draft
R6RS) forms +inf.0, -inf.0, and +nan.0 .
--
John Cowan http://ccil.org/~cowan address@hidden
We want more school houses and less jails; more books and less arsenals;
more learning and less vice; more constant work and less crime; more
leisure and less greed; more justice and less revenge; in fact, more of
the opportunities to cultivate our better natures. --Samuel Gompers
- [Chicken-users] IEEE float arithmetic,
John Cowan <=