|
From: | Thomas Chust |
Subject: | Re: [Chicken-users] IEEE float arithmetic |
Date: | Tue, 20 Jun 2006 08:28:27 +0200 (CEST) |
On Tue, 20 Jun 2006, felix winkelmann wrote:
On 6/19/06, John Cowan <address@hidden> wrote:[...] 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.Uh oh - I don't think this is good... Does it really give much to propagate nan's in thise case through numeric operations? [...]
Hello,in my humble opinion it is a good idea to throw an exception by default if a numerical operation does not make sense. This makes error detection in algorithms much easier. If CHICKEN did not throw exceptions in cases like division by zero, I would find myself wrapping tons of numerical operations in custom functions or macros in order to throw the exceptions by hand. In my eyes, performing those operations and returning some more or less sensible value is better suited for "unsafe" languages like C where you have to do error checking by hand anyway.
If you really want IEEE behaviour, I would suggest creating a native function:
(define ieee/ (foreign-lambda* double ((double n) (double d)) "return(n / d);"))Maybe something like that could be included in the library for completeness' sake. Or we should create an IEEE arithmetic egg (are there more functions than / in CHICKEN that are not IEEE compliant?). But I would really vote against modifying the behaviour of /.
cu, Thomas
[Prev in Thread] | Current Thread | [Next in Thread] |