[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] First batch of numerics changes

From: Mark H Weaver
Subject: Re: [PATCH] First batch of numerics changes
Date: Thu, 27 Jan 2011 17:06:19 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

I'm having second thoughts about two of the patches:

* Patch 0010: `inf?' and `nan?' throw exceptions when applied to

Previously, these predicates would return #f in that case.  I tend to
prefer strictness, but perhaps backward compatibility is more important
than strictness here.  What do you think?

* Patch 0018: Exact 0 times infinity or a NaN yields a NaN

Previously, exact 0 times anything yields exact 0.  This patch makes
exact 0 times any _finite_ number yield an exact 0, but makes exact 0
times an infinity or NaN yield a NaN.

This is a mistake.  A computation involving inexact arguments is
permitted to produce an exact answer only if the same answer would be
produced regardless of the value of the inexact arguments.

R6RS provides these examples, and gives us choices:

  (* 0 +inf.0) ==> 0 or +nan.0
  (* 0 +nan.0) ==> 0 or +nan.0
  (* 1.0 0)    ==> 0 or 0.0

But the choices are linked.  (* 0 n) may produce an exact 0 only if the
answer is exact 0 for _any_ value of n (including infinities or NaNs).

On the other hand, if we decide that the three cases above should return
an exact 0, then we are on mathematically questionable grounds.

  (/ 0.0)       ==> +inf.0   (required by R6RS)
  (* 0 +inf.0)  ==> 0        (one of two choices, per R6RS)
  (* 0 (/ 0.0)) ==> 0
  (/ 0 0.0)     ==> +nan.0   (required by R6RS)

The inconsistency of the last two cases does not sit well with me,
but in order to eliminate this inconsistency, we must concede that
exact 0 times any inexact number must produce an inexact result.

I am leaning toward the following:

  (* 0 +inf.0) ==> +nan.0
  (* 0 +nan.0) ==> +nan.0
  (* 0 1.0)    ==> 1.0
  (* 0 0.0)    ==> 0.0

What do you think?


reply via email to

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