unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* scm_difference big - -inum
@ 2003-08-22  1:18 Kevin Ryde
  0 siblings, 0 replies; only message in thread
From: Kevin Ryde @ 2003-08-22  1:18 UTC (permalink / raw)


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

I fixed a bit of a gremlin in "-",

        * numbers.c (scm_difference): Correction to bignum - negative inum.

        * tests/numbers.test (-): Exercise bignum - inum.


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

--- numbers.c.~1.197.~	2003-07-29 09:27:59.000000000 +1000
+++ numbers.c	2003-08-21 17:06:30.000000000 +1000
@@ -3370,7 +3370,10 @@
 	    {
 	      SCM result = scm_i_mkbig ();
 
-	      mpz_sub_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), yy);
+	      if (yy >= 0)
+		mpz_sub_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), yy);
+	      else
+		mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), -yy);
 	      scm_remember_upto_here_1 (x);
 
 	      if ((sgn_x < 0 && (yy > 0)) || ((sgn_x > 0) && yy < 0))

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

--- numbers.test.~1.30.~	1970-01-01 10:00:01.000000000 +1000
+++ numbers.test	2003-08-21 17:07:04.000000000 +1000
@@ -1784,7 +1784,15 @@
 
   (pass-if "-inum - +bignum"
     (= #x-100000000000000000000000000000001
-       (- -1 #x100000000000000000000000000000000))))
+       (- -1 #x100000000000000000000000000000000)))
+  
+  (pass-if "big - inum"
+    (= #xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+       (- #x100000000000000000000000000000000 1)))
+  
+  (pass-if "big - -inum"
+    (= #x100000000000000000000000000000001
+       (- #x100000000000000000000000000000000 -1))))
 
 ;;;
 ;;; *

[-- 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] only message in thread

only message in thread, other threads:[~2003-08-22  1:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-22  1:18 scm_difference big - -inum Kevin Ryde

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