* gcd inum/big simplification
@ 2004-04-15 1:41 Kevin Ryde
0 siblings, 0 replies; only message in thread
From: Kevin Ryde @ 2004-04-15 1:41 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 100 bytes --]
* numbers.c (scm_gcd): For inum/big, use mpz_gcd_ui by sharing code
with big/inum.
[-- Attachment #2: numbers.c.gcd-inum-big.diff --]
[-- Type: text/plain, Size: 955 bytes --]
--- numbers.c.~1.234.~ 2004-04-15 11:22:44.000000000 +1000
+++ numbers.c 2004-04-15 11:39:39.000000000 +1000
@@ -1026,15 +1026,8 @@
}
else if (SCM_BIGP (y))
{
- SCM result = scm_i_mkbig ();
- SCM mx = scm_i_mkbig ();
- mpz_set_si (SCM_I_BIG_MPZ (mx), SCM_INUM (x));
- scm_remember_upto_here_1 (x);
- mpz_gcd (SCM_I_BIG_MPZ (result),
- SCM_I_BIG_MPZ (mx),
- SCM_I_BIG_MPZ (y));
- scm_remember_upto_here_2 (mx, y);
- return scm_i_normbig (result);
+ SCM_SWAP (x, y);
+ goto big_inum;
}
else
SCM_WTA_DISPATCH_2 (g_gcd, x, y, SCM_ARG2, s_gcd);
@@ -1044,7 +1037,9 @@
if (SCM_INUMP (y))
{
unsigned long result;
- long yy = SCM_INUM (y);
+ long yy;
+ big_inum:
+ yy = SCM_INUM (y);
if (yy == 0)
return scm_abs (x);
if (yy < 0)
[-- Attachment #3: 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:[~2004-04-15 1:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-15 1:41 gcd inum/big simplification 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).