From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: min,max big/real exactness Date: Tue, 23 Mar 2004 08:43:01 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87zna8wlje.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1079995530 13750 80.91.224.253 (22 Mar 2004 22:45:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 22 Mar 2004 22:45:30 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Mar 22 23:45:06 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B5YAL-0002Ko-00 for ; Mon, 22 Mar 2004 23:45:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B5Y9m-0005qV-3J for guile-devel@m.gmane.org; Mon, 22 Mar 2004 17:44:30 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B5Y99-0005pI-MB for guile-devel@gnu.org; Mon, 22 Mar 2004 17:43:51 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B5Y8d-0005f5-Re for guile-devel@gnu.org; Mon, 22 Mar 2004 17:43:50 -0500 Original-Received: from [61.8.0.85] (helo=mailout2.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B5Y8c-0005da-Vg for guile-devel@gnu.org; Mon, 22 Mar 2004 17:43:19 -0500 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86]) by mailout2.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i2MMhC5v021795 for ; Tue, 23 Mar 2004 09:43:12 +1100 Original-Received: from localhost (ppp112.dyn11.pacific.net.au [61.8.11.112]) by mailproxy1.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i2MMhAGP027176 for ; Tue, 23 Mar 2004 09:43:11 +1100 Original-Received: from gg by localhost with local (Exim 3.36 #1 (Debian)) id 1B5Y8L-0000el-00; Tue, 23 Mar 2004 08:43:01 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3562 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3562 --=-=-= * numbers.c (scm_min, scm_max): Correction to big/real and real/big, return inexact as required by r5rs. * tests/numbers.test (min, max): Check inexactness of big/real and real/big combinations, collect up tests under arg types for clarity. The inexactness of inum/real and real/inum is exercised by r4rs.test, but big combos slipped through. --=-=-= Content-Disposition: inline; filename=numbers.c.min-max-inexact.diff --- numbers.c.~1.224.~ 2004-02-22 08:02:53.000000000 +1000 +++ numbers.c 2004-03-22 18:46:23.000000000 +1000 @@ -3442,13 +3442,10 @@ } else if (SCM_REALP (y)) { + /* if y==NaN then xx>yy is false, so we return the NaN y */ + double xx = scm_i_big2dbl (x); double yy = SCM_REAL_VALUE (y); - int cmp; - if (xisnan (yy)) - return y; - cmp = xmpz_cmp_d (SCM_I_BIG_MPZ (x), yy); - scm_remember_upto_here_1 (x); - return (cmp > 0) ? x : y; + return (xx > yy ? scm_make_real (xx) : y); } else if (SCM_FRACTIONP (y)) { @@ -3471,13 +3468,10 @@ } else if (SCM_BIGP (y)) { + /* if x==NaN then yy>xx is false, so we return the NaN x */ double xx = SCM_REAL_VALUE (x); - int cmp; - if (xisnan (xx)) - return x; - cmp = xmpz_cmp_d (SCM_I_BIG_MPZ (y), xx); - scm_remember_upto_here_1 (y); - return (cmp < 0) ? x : y; + double yy = scm_i_big2dbl (y); + return (yy > xx ? scm_make_real (yy) : x); } else if (SCM_REALP (y)) { @@ -3591,13 +3585,10 @@ } else if (SCM_REALP (y)) { + /* if y==NaN then xx 0) ? y : x; + return (xx < yy ? scm_make_real (xx) : y); } else if (SCM_FRACTIONP (y)) { @@ -3620,13 +3611,10 @@ } else if (SCM_BIGP (y)) { - double xx = SCM_REAL_VALUE (x); - int cmp; - if (xisnan (xx)) - return x; - cmp = xmpz_cmp_d (SCM_I_BIG_MPZ (y), xx); - scm_remember_upto_here_1 (y); - return (cmp < 0) ? y : x; + /* if x==NaN then yy