chicken-hackers
[Top][All Lists]
Advanced

[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: Thu, 16 Jun 2011 16:44:40 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

felix scripsit:

> Well, there is a floating-point specific operator that behaves
> according to IEEE (on those platforms that do, that is): "fpexpt". In
> most cases, informing the user of such a situation may be
> desirable. Would you suggest "(/ 1 0)" should return NaN as well?

By no means.  But I think (/ 1.0 0.0), and variants of that, should
return +inf.0 rather than throwing an exception.  Floating-point zero
is not necessarily a true zero; it's just a number too close to zero to
represent.  Its reciprocal therefore is a number too big to represent
precisely.  OTOH, (/ 0.0 0.0) should return +nan.0.

Of the Schemes I routinely test with, Racket, Gauche, Gambit, Bigloo,
Guile, Kawa, Scheme48, SISC, Chibi, Chez, Ikarus, Larceny, IronScheme,
Ypsilon, Mosh, and STklos all behave as I suggest.  Only MIT, Chicken,
and scsh throw exceptions.  Scheme 9 throws an exception for (/ 1.0 0.0)
but returns 0.0 for (/ 0.0 0.0).

None of this applies, or should apply, to exact numbers: both (/ 1 0)
and (/ 0 0) should throw exceptions.

-- 
John Cowan   http://ccil.org/~cowan  address@hidden
[P]olice in many lands are now complaining that local arrestees are insisting
on having their Miranda rights read to them, just like perps in American TV
cop shows.  When it's explained to them that they are in a different country,
where those rights do not exist, they become outraged.  --Neal Stephenson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]