guile-devel
[Top][All Lists]
Advanced

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

[PATCH] Handle products with exact 0 differently, etc


From: Mark H Weaver
Subject: [PATCH] Handle products with exact 0 differently, etc
Date: Tue, 01 Feb 2011 07:09:39 -0500

Here's another batch of numerics patches.  The most important one
changes the way products involving exact 0 are handled:

* libguile/numbers.c (scm_product): Handle exact 0 differently.  A
  product containing an exact 0 now returns an exact 0 if and only if
  the other arguments are all exact.  An inexact zero is returned if and
  only if the other arguments are all finite but not all exact.  If an
  infinite or NaN value is present, a NaN value is returned.
  Previously, any product containing an exact 0 yielded an exact 0,
  regardless of the other arguments.

  A note on the rationale for (* 0 0.0) returning 0.0 and not exact 0:
  The exactness propagation rules allow us to return an exact result in
  the presence of inexact arguments only if the values of the inexact
  arguments do not affect the result.  In this case, the value of the
  inexact argument _does_ affect the result, because an infinite or NaN
  value causes the result to be a NaN.

  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)),
  and in particular, for (/ 0 0.0) to be the same as (* 0 (/ 0.0)),
  which reduces to (* 0 +inf.0).  Therefore (* 0 +inf.0) should return
  a NaN.

     Best,
      Mark


Attachment: 0001-Fix-bugs-in-rationalize.patch
Description: Fix bugs in `rationalize'

Attachment: 0002-More-discriminating-NaN-predicates-for-numbers.test.patch
Description: More discriminating NaN predicates for numbers.test

Attachment: 0003-Handle-products-with-exact-0-differently.patch
Description: Handle products with exact 0 differently

Attachment: 0004-Move-comment-about-trig-functions-back-where-it-belo.patch
Description: Move comment about trig functions back where it belongs

Attachment: 0005-Trigonometric-functions-return-exact-numbers-in-some.patch
Description: Trigonometric functions return exact numbers in some cases

Attachment: 0006-Improve-discussion-of-exactness-propagation-in-manua.patch
Description: Improve discussion of exactness propagation in manual


reply via email to

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