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: scm_difference gremlin Date: Sun, 04 May 2003 09:29:14 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87u1cblid1.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1052004798 32465 80.91.224.249 (3 May 2003 23:33:18 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 3 May 2003 23:33:18 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun May 04 01:33:16 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19C6VH-0008RR-00 for ; Sun, 04 May 2003 01:33:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19C6W6-0004vk-05 for guile-devel@m.gmane.org; Sat, 03 May 2003 19:34:06 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19C6SC-0003lQ-00 for guile-devel@gnu.org; Sat, 03 May 2003 19:30:04 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19C6Rf-0003Mj-00 for guile-devel@gnu.org; Sat, 03 May 2003 19:29:35 -0400 Original-Received: from snoopy.pacific.net.au ([61.8.0.36]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19C6Rc-000395-00 for guile-devel@gnu.org; Sat, 03 May 2003 19:29:28 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) h43NTPs7028015 for ; Sun, 4 May 2003 09:29:25 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h43NTPQg000160 for ; Sun, 4 May 2003 09:29:25 +1000 (EST) Original-Received: from localhost (ppp30.dyn228.pacific.net.au [203.143.228.30]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h43NTNYZ022245 for ; Sun, 4 May 2003 09:29:24 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19C6RO-0001rY-00; Sun, 04 May 2003 09:29:14 +1000 Original-To: guile-devel@gnu.org User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2253 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2253 --=-=-= A small bug in scm_difference, * numbers.c (scm_difference): In inum - bignum, handle negative inum. * tests/numbers.test (-): Add test for negative inum subtract bignum. --=-=-= Content-Disposition: attachment; filename=numbers.c.inum-sub-bignum.diff --- numbers.c.~1.181.~ 2003-05-04 09:09:49.000000000 +1000 +++ numbers.c 2003-05-04 09:25:07.000000000 +1000 @@ -3060,7 +3060,14 @@ int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y)); SCM result = scm_i_mkbig (); - mpz_ui_sub (SCM_I_BIG_MPZ (result), xx, SCM_I_BIG_MPZ (y)); + if (xx >= 0) + mpz_ui_sub (SCM_I_BIG_MPZ (result), xx, SCM_I_BIG_MPZ (y)); + else + { + /* x - y == -(y + -x) */ + mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (y), -xx); + mpz_neg (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (result)); + } scm_remember_upto_here_1 (y); if ((xx < 0 && (sgn_y > 0)) || ((xx > 0) && sgn_y < 0)) --=-=-= Content-Disposition: attachment; filename=numbers.test.inum-sub-bignum.diff --- numbers.test.~1.17.~ 2003-05-04 09:11:34.000000000 +1000 +++ numbers.test 2003-05-04 09:27:55.000000000 +1000 @@ -1,5 +1,5 @@ ;;;; numbers.test --- tests guile's numbers -*- scheme -*- -;;;; Copyright (C) 2000, 2001 Free Software Foundation, Inc. +;;;; Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -1609,6 +1609,12 @@ ;;; - ;;; +(with-test-prefix "-" + + (pass-if "-inum - +bignum" + (= #x-100000000000000000000000000000001 + (- -1 #x100000000000000000000000000000000)))) + ;;; ;;; * ;;; --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--