mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-22 07:09:18 +02:00
Another off-by-one error in ash.
This commit is contained in:
parent
9dd60f6f13
commit
a2e4f1dc96
2 changed files with 3 additions and 2 deletions
|
@ -159,11 +159,11 @@ static sexp sexp_arithmetic_shift (sexp ctx, sexp self, sexp_sint_t n, sexp i, s
|
|||
if (c < 0) {
|
||||
res = sexp_make_fixnum(sexp_unbox_fixnum(i) >> -c);
|
||||
} else {
|
||||
tmp = (sexp_uint_t)sexp_unbox_fixnum(i) << c;
|
||||
#if SEXP_USE_BIGNUMS
|
||||
if ((log2i(sexp_unbox_fixnum(i)) + c)
|
||||
if ((log2i(sexp_unbox_fixnum(i)) + c + 1)
|
||||
< (sizeof(sexp_uint_t)*CHAR_BIT - SEXP_FIXNUM_BITS)) {
|
||||
#endif
|
||||
tmp = (sexp_uint_t)sexp_unbox_fixnum(i) << c;
|
||||
res = sexp_make_fixnum(tmp * sexp_fx_sign(i));
|
||||
#if SEXP_USE_BIGNUMS
|
||||
} else {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
(test (expt 2 127) (arithmetic-shift 1 127))
|
||||
(test (expt 2 128) (arithmetic-shift 1 128))
|
||||
(test (expt 2 129) (arithmetic-shift 1 129))
|
||||
(test 3028397001194014464 (arithmetic-shift 11829675785914119 8))
|
||||
|
||||
(test -1 (arithmetic-shift -1 0))
|
||||
(test -2 (arithmetic-shift -1 1))
|
||||
|
|
Loading…
Add table
Reference in a new issue