unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* scm_difference gremlin
@ 2003-05-03 23:29 Kevin Ryde
  2003-05-04  0:14 ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2003-05-03 23:29 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

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.


[-- Attachment #2: numbers.c.inum-sub-bignum.diff --]
[-- Type: text/plain, Size: 739 bytes --]

--- 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))

[-- Attachment #3: numbers.test.inum-sub-bignum.diff --]
[-- Type: text/plain, Size: 673 bytes --]

--- 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))))
+
 ;;;
 ;;; *
 ;;;

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: scm_difference gremlin
  2003-05-03 23:29 scm_difference gremlin Kevin Ryde
@ 2003-05-04  0:14 ` Marius Vollmer
  2003-05-04  4:57   ` Rob Browning
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Vollmer @ 2003-05-04  0:14 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde <user42@zip.com.au> writes:

> A small bug in scm_difference,

Excellent, please apply (when Rob doesn't object).

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: scm_difference gremlin
  2003-05-04  0:14 ` Marius Vollmer
@ 2003-05-04  4:57   ` Rob Browning
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Browning @ 2003-05-04  4:57 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer <mvo@zagadka.de> writes:

>> A small bug in scm_difference,
>
> Excellent, please apply (when Rob doesn't object).

No objection here.

Thanks

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-04  4:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-03 23:29 scm_difference gremlin Kevin Ryde
2003-05-04  0:14 ` Marius Vollmer
2003-05-04  4:57   ` Rob Browning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).