HCoop
/
bpt
/
guile.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
14b454a
)
(scm_difference): In inum - bignum, handle negative inum.
author
Kevin Ryde
<user42@zip.com.au>
Mon, 5 May 2003 22:55:46 +0000
(22:55 +0000)
committer
Kevin Ryde
<user42@zip.com.au>
Mon, 5 May 2003 22:55:46 +0000
(22:55 +0000)
libguile/numbers.c
patch
|
blob
|
blame
|
history
diff --git
a/libguile/numbers.c
b/libguile/numbers.c
index
7fa97c4
..
602682d
100644
(file)
--- a/
libguile/numbers.c
+++ b/
libguile/numbers.c
@@
-3060,7
+3060,14
@@
scm_difference (SCM x, SCM y)
int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
SCM result = scm_i_mkbig ();
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))
scm_remember_upto_here_1 (y);
if ((xx < 0 && (sgn_y > 0)) || ((xx > 0) && sgn_y < 0))