GNU bug report logs - #16365
(* 0 +inf.0) rationale is flawed

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Zefram <zefram@HIDDEN>; dated Mon, 6 Jan 2014 00:18:01 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 16365 <at> debbugs.gnu.org:


Received: (at 16365) by debbugs.gnu.org; 21 Jun 2016 14:21:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 21 10:21:36 2016
Received: from localhost ([127.0.0.1]:49851 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bFMYa-00056M-6R
	for submit <at> debbugs.gnu.org; Tue, 21 Jun 2016 10:21:36 -0400
Received: from river.fysh.org ([87.98.248.19]:43731 ident=Debian-exim)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zefram@HIDDEN>) id 1bFMYX-00056B-QC
 for 16365 <at> debbugs.gnu.org; Tue, 21 Jun 2016 10:21:34 -0400
Received: from zefram by river.fysh.org with local (Exim 4.84_2 #1 (Debian))
 id 1bFMYU-00034A-24; Tue, 21 Jun 2016 15:21:30 +0100
Date: Tue, 21 Jun 2016 15:21:30 +0100
From: Zefram <zefram@HIDDEN>
To: Mark H Weaver <mhw@HIDDEN>
Subject: Re: bug#16365: (* 0 +inf.0) rationale is flawed
Message-ID: <20160621142130.GA1170@HIDDEN>
References: <20140106001719.GI21945@HIDDEN> <87r3bqzpbd.fsf@HIDDEN>
 <87vb12skz7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <87vb12skz7.fsf@HIDDEN>
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: 16365
Cc: Andy Wingo <wingo@HIDDEN>, 16365 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

Mark H Weaver wrote:
>         I also suspect that (/ 0 <anything_but_exact_0>) should be 0,
>although that conflicts with R6RS.  We should probably investigate the
>rationale behind R6RS's decision to specify that (/ 0 0.0) returns a NaN
>before changing that, though.

I think R6RS makes sense for (/ 0 0.0).  A flonum zero really represents
a range of values including both small non-zero numbers and actual zero.
The mathematical result of the division could therefore be either zero or
undefined.  To return zero for it would be picking a particular result,
on the assumption that the flonum zero actually represented a non-zero
value, and that's not justified.  So to use the flonum behaviour seems
the best thing available.

(/ 0 3.5) is a different case.  Here the mathematical result is an
exact zero, and I'm surprised that R6RS specifies that this should be
an inexact zero.  This seems inconsistent with (* 1.0 0), for which it
specifies that the result may be either 0 or 0.0.

I'd also question R6RS in the related case of (/ 0.0 0).  Mathematically
this division is definitely an error, regardless of whether the dividend
represents zero or a non-zero number.  So it would make sense for this
to raise an exception in the same manner as (/ 3 0) or (/ 0 0), rather
than get flonum treatment as R6RS specifies.

But deviating from R6RS, even with a good rationale for other behaviour,
would be a bad idea.  The questionable R6RS requirements are not crazy,
just suboptimal.  The case I originally raised, (* 0 +inf.0), is one
for which R6RS offers the choice.

-zefram




Information forwarded to bug-guile@HIDDEN:
bug#16365; Package guile. Full text available.

Message received at 16365 <at> debbugs.gnu.org:


Received: (at 16365) by debbugs.gnu.org; 21 Jun 2016 13:57:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 21 09:57:53 2016
Received: from localhost ([127.0.0.1]:49836 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bFMBd-0004Wr-Du
	for submit <at> debbugs.gnu.org; Tue, 21 Jun 2016 09:57:53 -0400
Received: from world.peace.net ([50.252.239.5]:34602)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mhw@HIDDEN>) id 1bFMBb-0004WI-W4
 for 16365 <at> debbugs.gnu.org; Tue, 21 Jun 2016 09:57:52 -0400
Received: from [206.35.36.10] (helo=jojen)
 by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <mhw@HIDDEN>)
 id 1bFMBV-00030v-4m; Tue, 21 Jun 2016 09:57:45 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: Andy Wingo <wingo@HIDDEN>
Subject: Re: bug#16365: (* 0 +inf.0) rationale is flawed
References: <20140106001719.GI21945@HIDDEN> <87r3bqzpbd.fsf@HIDDEN>
Date: Tue, 21 Jun 2016 09:57:32 -0400
In-Reply-To: <87r3bqzpbd.fsf@HIDDEN> (Andy Wingo's message of "Tue, 21 Jun
 2016 14:41:58 +0200")
Message-ID: <87vb12skz7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 16365
Cc: Zefram <zefram@HIDDEN>, 16365 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

Andy Wingo <wingo@HIDDEN> writes:
> Thoughts, Mark?

Sorry for the long delay on this, but briefly, I agree that my rationale
was flawed, and that we should make (* 0 <anything>) == 0 in all cases
in 2.2.  I also suspect that (/ 0 <anything_but_exact_0>) should be 0,
although that conflicts with R6RS.  We should probably investigate the
rationale behind R6RS's decision to specify that (/ 0 0.0) returns a NaN
before changing that, though.

I hope to work more on this soon.

      Thanks,
        Mark


> On Mon 06 Jan 2014 01:17, Zefram <zefram@HIDDEN> writes:
>
>> Commit 5e7918077a4015768a352ab19e4a8e94531bc8aa says
>>
>>       A note on the rationale for (* 0 +inf.0) being a NaN and not exact 0:
>>       The R6RS requires that (/ 0 0.0) return a NaN value, and that (/ 0.0)
>>       return +inf.0.  We would like (/ x y) to be the same as (* x (/ y)),
>>
>> This identity doesn't actually hold.  For example, on guile 2.0.9 with
>> IEEE double flonums:
>>
>> scheme@(guile-user)> (/ (expt 2.0 -20) (expt 2.0 -1026))
>> $36 = 6.857655085992111e302
>> scheme@(guile-user)> (* (expt 2.0 -20) (/ (expt 2.0 -1026)))
>> $37 = +inf.0
>>
>> This case arises because the dynamic range of this flonum format is
>> slightly asymmetric: 2^-1026 is representable, but 2^1026 overflows.
>>
>> So the rationale for (* 0 +inf.0) yielding +nan.0 is flawed.  As the
>> supposed invariant and the rationale are not in the actual documentation
>> (only mentioned in the commit log) this is not necessarily a bug.
>> But worth thinking again to determine whether the case for adopting
>> the flonum behaviour here is still stronger than the obvious case for
>> the exact zero to predominate.  (Mathematically, multiplying zero by an
>> infinite number does yield zero.  Let alone multiplying it by a merely
>> large finite number, which is what the flonum indefinite `infinity'
>> really represents.)
>>
>> -zefram




Information forwarded to bug-guile@HIDDEN:
bug#16365; Package guile. Full text available.

Message received at 16365 <at> debbugs.gnu.org:


Received: (at 16365) by debbugs.gnu.org; 21 Jun 2016 12:42:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 21 08:42:10 2016
Received: from localhost ([127.0.0.1]:48720 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bFL0M-0002Lw-1L
	for submit <at> debbugs.gnu.org; Tue, 21 Jun 2016 08:42:10 -0400
Received: from pb-sasl1.pobox.com ([64.147.108.66]:52556
 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <wingo@HIDDEN>) id 1bFL0K-0002Lp-Ht
 for 16365 <at> debbugs.gnu.org; Tue, 21 Jun 2016 08:42:08 -0400
Received: from sasl.smtp.pobox.com (unknown [127.0.0.1])
 by pb-sasl1.pobox.com (Postfix) with ESMTP id B622E22AEF;
 Tue, 21 Jun 2016 08:42:06 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc
 :subject:references:date:in-reply-to:message-id:mime-version
 :content-type; s=sasl; bh=yIfwRR9zfSwwK+DZbRAxssILQIU=; b=n6dpbu
 w7k8Lu1zlFTuWAR0kvCxCVdEf9CJ2v1chb+oz2cqeUJ5Uxl2p0pGsEapq6ngVvdh
 AL1vZ2IRmD0VC3u1go4+/vAgezrAmN2eRLBLgLgMOERnIYXiB6nFYuCcoNSJyCzO
 MYcnT4dVYXSpOgwKkTEO4wkjKMySrlISDy8Ck=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc
 :subject:references:date:in-reply-to:message-id:mime-version
 :content-type; q=dns; s=sasl; b=u0Mkq+0RatoPt8Ekg2uBBrFISv06tsz9
 WULj+fTxppwfF5bOjGu/dEy4QknJ9acMqPZ1F1H7JQNKffwnrSBQrQ7Yon7EhM/A
 4brgnYcrpnaKQGEP25rflAENsxFbtsDL5WJVr6T0ZsA/BfecopfUP4S0UbuwTyK0
 VoZ1tXm1qUs=
Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1])
 by pb-sasl1.pobox.com (Postfix) with ESMTP id AE77322AED;
 Tue, 21 Jun 2016 08:42:06 -0400 (EDT)
Received: from clucks (unknown [88.160.190.192])
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by pb-sasl1.pobox.com (Postfix) with ESMTPSA id C26BB22AEC;
 Tue, 21 Jun 2016 08:42:05 -0400 (EDT)
From: Andy Wingo <wingo@HIDDEN>
To: mhw@HIDDEN
Subject: Re: bug#16365: (* 0 +inf.0) rationale is flawed
References: <20140106001719.GI21945@HIDDEN>
Date: Tue, 21 Jun 2016 14:41:58 +0200
In-Reply-To: <20140106001719.GI21945@HIDDEN> (zefram@HIDDEN's message of
 "Mon, 6 Jan 2014 00:17:19 +0000")
Message-ID: <87r3bqzpbd.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Pobox-Relay-ID: 8FB0BE02-37AD-11E6-AE4A-C1836462E9F6-02397024!pb-sasl1.pobox.com
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: 16365
Cc: Zefram <zefram@HIDDEN>, 16365 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

Thoughts, Mark?

On Mon 06 Jan 2014 01:17, Zefram <zefram@HIDDEN> writes:

> Commit 5e7918077a4015768a352ab19e4a8e94531bc8aa says
>
>       A note on the rationale for (* 0 +inf.0) being a NaN and not exact 0:
>       The R6RS requires that (/ 0 0.0) return a NaN value, and that (/ 0.0)
>       return +inf.0.  We would like (/ x y) to be the same as (* x (/ y)),
>
> This identity doesn't actually hold.  For example, on guile 2.0.9 with
> IEEE double flonums:
>
> scheme@(guile-user)> (/ (expt 2.0 -20) (expt 2.0 -1026))
> $36 = 6.857655085992111e302
> scheme@(guile-user)> (* (expt 2.0 -20) (/ (expt 2.0 -1026)))
> $37 = +inf.0
>
> This case arises because the dynamic range of this flonum format is
> slightly asymmetric: 2^-1026 is representable, but 2^1026 overflows.
>
> So the rationale for (* 0 +inf.0) yielding +nan.0 is flawed.  As the
> supposed invariant and the rationale are not in the actual documentation
> (only mentioned in the commit log) this is not necessarily a bug.
> But worth thinking again to determine whether the case for adopting
> the flonum behaviour here is still stronger than the obvious case for
> the exact zero to predominate.  (Mathematically, multiplying zero by an
> infinite number does yield zero.  Let alone multiplying it by a merely
> large finite number, which is what the flonum indefinite `infinity'
> really represents.)
>
> -zefram




Information forwarded to bug-guile@HIDDEN:
bug#16365; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 6 Jan 2014 00:17:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 05 19:17:33 2014
Received: from localhost ([127.0.0.1]:37310 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Vzxsq-00073J-Lm
	for submit <at> debbugs.gnu.org; Sun, 05 Jan 2014 19:17:33 -0500
Received: from eggs.gnu.org ([208.118.235.92]:54758)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <zefram@HIDDEN>) id 1Vzxso-00073B-Gm
 for submit <at> debbugs.gnu.org; Sun, 05 Jan 2014 19:17:31 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <zefram@HIDDEN>) id 1Vzxsn-0001ed-Dh
 for submit <at> debbugs.gnu.org; Sun, 05 Jan 2014 19:17:30 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:41153)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <zefram@HIDDEN>) id 1Vzxsn-0001eZ-9o
 for submit <at> debbugs.gnu.org; Sun, 05 Jan 2014 19:17:29 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56468)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <zefram@HIDDEN>) id 1Vzxsm-00045I-4J
 for bug-guile@HIDDEN; Sun, 05 Jan 2014 19:17:29 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <zefram@HIDDEN>) id 1Vzxsl-0001dL-CK
 for bug-guile@HIDDEN; Sun, 05 Jan 2014 19:17:28 -0500
Received: from river.fysh.org ([2001:41d0:8:d47f::2]:52604)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <zefram@HIDDEN>) id 1Vzxsl-0001d0-5m
 for bug-guile@HIDDEN; Sun, 05 Jan 2014 19:17:27 -0500
Received: from zefram by river.fysh.org with local (Exim 4.80 #2 (Debian))
 id 1Vzxsd-0002kF-SG; Mon, 06 Jan 2014 00:17:19 +0000
Date: Mon, 6 Jan 2014 00:17:19 +0000
From: Zefram <zefram@HIDDEN>
To: bug-guile@HIDDEN
Subject: (* 0 +inf.0) rationale is flawed
Message-ID: <20140106001719.GI21945@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

Commit 5e7918077a4015768a352ab19e4a8e94531bc8aa says

      A note on the rationale for (* 0 +inf.0) being a NaN and not exact 0:
      The R6RS requires that (/ 0 0.0) return a NaN value, and that (/ 0.0)
      return +inf.0.  We would like (/ x y) to be the same as (* x (/ y)),

This identity doesn't actually hold.  For example, on guile 2.0.9 with
IEEE double flonums:

scheme@(guile-user)> (/ (expt 2.0 -20) (expt 2.0 -1026))
$36 = 6.857655085992111e302
scheme@(guile-user)> (* (expt 2.0 -20) (/ (expt 2.0 -1026)))
$37 = +inf.0

This case arises because the dynamic range of this flonum format is
slightly asymmetric: 2^-1026 is representable, but 2^1026 overflows.

So the rationale for (* 0 +inf.0) yielding +nan.0 is flawed.  As the
supposed invariant and the rationale are not in the actual documentation
(only mentioned in the commit log) this is not necessarily a bug.
But worth thinking again to determine whether the case for adopting
the flonum behaviour here is still stronger than the obvious case for
the exact zero to predominate.  (Mathematically, multiplying zero by an
infinite number does yield zero.  Let alone multiplying it by a merely
large finite number, which is what the flonum indefinite `infinity'
really represents.)

-zefram




Acknowledgement sent to Zefram <zefram@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#16365; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.