diff options
author | Mark H Weaver <mhw@netris.org> | 2014-04-25 02:06:01 -0400 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2014-04-25 02:06:01 -0400 |
commit | 475772ea57c97d0fa0f9ed9303db137d9798ddd3 (patch) | |
tree | 99a9ba2ea0b044552016d41c5c9197bbac66d97f /libguile/numbers.c | |
parent | 0e92ef40d047696eb3334405b2dd32f51ca55006 (diff) | |
parent | e0da53b4fe4abee2cdcd97fe46eeefcaab1da631 (diff) | |
download | guile-475772ea57c97d0fa0f9ed9303db137d9798ddd3.tar.gz |
Merge branch 'stable-2.0'v2.1.0
Conflicts:
GUILE-VERSION
NEWS
guile-readline/ice-9/readline.scm
libguile/async.c
libguile/backtrace.c
libguile/deprecated.h
libguile/gc-malloc.c
libguile/gdbint.c
libguile/init.c
libguile/ioext.c
libguile/mallocs.c
libguile/print.c
libguile/rw.c
libguile/scmsigs.c
libguile/script.c
libguile/simpos.c
libguile/snarf.h
libguile/strports.c
libguile/threads.c
libguile/vm-i-scheme.c
libguile/vm-i-system.c
module/srfi/srfi-18.scm
test-suite/Makefile.am
test-suite/standalone/test-num2integral.c
Diffstat (limited to 'libguile/numbers.c')
-rw-r--r-- | libguile/numbers.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c index f4e8b2710..14d98ffea 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -1,6 +1,6 @@ /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, * 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, - * 2013 Free Software Foundation, Inc. + * 2013, 2014 Free Software Foundation, Inc. * * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories * and Bellcore. See scm_divide. @@ -4679,9 +4679,15 @@ SCM_DEFINE (scm_logbit_p, "logbit?", 2, 0, 0, if (SCM_I_INUMP (j)) { - /* bits above what's in an inum follow the sign bit */ - iindex = min (iindex, SCM_LONG_BIT - 1); - return scm_from_bool ((1L << iindex) & SCM_I_INUM (j)); + if (iindex < SCM_LONG_BIT - 1) + /* Arrange for the number to be converted to unsigned before + checking the bit, to ensure that we're testing the bit in a + two's complement representation (regardless of the native + representation. */ + return scm_from_bool ((1UL << iindex) & SCM_I_INUM (j)); + else + /* Portably check the sign. */ + return scm_from_bool (SCM_I_INUM (j) < 0); } else if (SCM_BIGP (j)) { @@ -4991,7 +4997,7 @@ left_shift_exact_integer (SCM n, long count) else if (count < SCM_I_FIXNUM_BIT-1 && ((scm_t_bits) (SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - count)) + 1) <= 1)) - return SCM_I_MAKINUM (nn << count); + return SCM_I_MAKINUM (nn < 0 ? -(-nn << count) : (nn << count)); else { SCM result = scm_i_inum2big (nn); |