[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] CR: expt should signal error on domain error
From: |
John Cowan |
Subject: |
Re: [Chicken-hackers] CR: expt should signal error on domain error |
Date: |
Mon, 4 Jul 2011 02:47:01 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Felix scripsit:
> * Those who want IEEE behaviour can have it using "fpexpt".
True. However, I tend to expect that the fp* functions will provide
efficient versions of the regular procedures (because they know their
arguments are flonums) rather than returning different results.
> * I think that it makes sense to fail fast when the result of an
> operation can not be properly represented in the system, due to
> implementation restrictions.
I think this is a good idea in general, but false in some particular
cases, and floating-point is one of them. I think it's valuable that
flonums are closed under all operations in the default Chicken numeric
mode (that is, without complex numbers), while leaving an indication in
the form of NaN that something has gone wrong.
> * Not all users expect or appreciate IEEE behaviour for such an
> operation and so +NaN may be unintuitive,
Flonums *aren't* intuitive unless you understand them. For intuitive
behavior, use exact numbers. For speed, use flonums.
> since other numerical operations clearly fail when encountering a
> domain error (and fail because it matches what people usually expect,
> for example in the case of div-by-zero).
As I've said before, I think that dividing by inexact zero should not
cause an exception either. All inexact numbers represent a range
with the exception of some uses of NaN (sometimes NaN means "any
number", sometimes it means "no possible number"). In particular, 0.0
represents the range from the smallest positive flonum (exclusive) to
zero (inclusive), as -0.0 represents the range from the largest negative
flonum (exclusive) to zero (inclusive). Dividing by 0.0 or -0.0 should
therefore produce +inf.0 or -inf.0 respectively, flonums whose range is
from the largest/smallest flonum (exclusive) up to infinity (inclusive).
--
But you, Wormtongue, you have done what you could for your true master. Some
reward you have earned at least. Yet Saruman is apt to overlook his bargains.
I should advise you to go quickly and remind him, lest he forget your faithful
service. --Gandalf John Cowan <address@hidden>