summaryrefslogtreecommitdiff
path: root/libguile/numbers.c
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2013-01-07 17:23:26 -0500
committerMark H Weaver <mhw@netris.org>2013-01-07 17:23:26 -0500
commite0c211bb2e80605b4ae3fb121c34136f6e266b70 (patch)
tree15d7e55519b83b124c836443d6045df78e3ad2ba /libguile/numbers.c
parent110ef00ba1dfae4461afdd189fed4dfec05ee137 (diff)
parent9f17d967c9b108f856776c035462e93017a6e7e2 (diff)
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts: GUILE-VERSION libguile/posix.c module/ice-9/eval.scm test-suite/tests/cse.test
Diffstat (limited to 'libguile/numbers.c')
-rw-r--r--libguile/numbers.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 63a6501dd..01f8e05ac 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -7643,10 +7643,16 @@ scm_product (SCM x, SCM y)
if (SCM_LIKELY (SCM_I_INUMP (y)))
{
scm_t_inum yy = SCM_I_INUM (y);
- scm_t_inum kk = xx * yy;
- SCM k = SCM_I_MAKINUM (kk);
- if ((kk == SCM_I_INUM (k)) && (kk / xx == yy))
- return k;
+#if SCM_I_FIXNUM_BIT < 32 && SCM_HAVE_T_INT64
+ scm_t_int64 kk = xx * (scm_t_int64) yy;
+ if (SCM_FIXABLE (kk))
+ return SCM_I_MAKINUM (kk);
+#else
+ scm_t_inum axx = (xx > 0) ? xx : -xx;
+ scm_t_inum ayy = (yy > 0) ? yy : -yy;
+ if (SCM_MOST_POSITIVE_FIXNUM / axx >= ayy)
+ return SCM_I_MAKINUM (xx * yy);
+#endif
else
{
SCM result = scm_i_inum2big (xx);