diff --git a/pkgs/r6rs-pkgs/r6rs-test/tests/r6rs/arithmetic/bitwise.sls b/pkgs/r6rs-pkgs/r6rs-test/tests/r6rs/arithmetic/bitwise.sls index 7707b5a6ea..6cebbbf3f7 100644 --- a/pkgs/r6rs-pkgs/r6rs-test/tests/r6rs/arithmetic/bitwise.sls +++ b/pkgs/r6rs-pkgs/r6rs-test/tests/r6rs/arithmetic/bitwise.sls @@ -44,6 +44,10 @@ (test (bitwise-arithmetic-shift -3 -1) -2) (test (bitwise-arithmetic-shift -2 -1) -1) (test (bitwise-arithmetic-shift -1 -1) -1) + + (test (bitwise-arithmetic-shift-right 42 (greatest-fixnum)) 0) + (test (bitwise-arithmetic-shift-right 42 (+ 1 (greatest-fixnum))) 0) + (test (bitwise-arithmetic-shift-right 42 (+ 2 (greatest-fixnum))) 0) (test (bitwise-reverse-bit-field #b1010010 1 4) 88) ; #b1011000 diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/number.rktl b/pkgs/racket-pkgs/racket-test/tests/racket/number.rktl index ab77f6b48f..47eef1856f 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/number.rktl +++ b/pkgs/racket-pkgs/racket-test/tests/racket/number.rktl @@ -1181,6 +1181,10 @@ (test 0 arithmetic-shift (sub1 (expt 2 32)) -32) (test 1 arithmetic-shift (expt 2 32) -32) +(for ([i (in-range -2 3)]) + (test 0 arithmetic-shift 42 (+ i (- (expt 2 31)))) + (test 0 arithmetic-shift 42 (+ i (- (expt 2 63))))) + (arity-test arithmetic-shift 2 2) (err/rt-test (arithmetic-shift "a" 1)) (err/rt-test (arithmetic-shift 1 "a")) diff --git a/racket/src/racket/src/number.c b/racket/src/racket/src/number.c index 1f4e4e3f08..ead243db27 100644 --- a/racket/src/racket/src/number.c +++ b/racket/src/racket/src/number.c @@ -4120,7 +4120,7 @@ scheme_bitwise_shift(int argc, Scheme_Object *argv[]) if (i > 0) { if (shift < 0) { - int shft = -shift; + intptr_t shft = -shift; if (shft < MAX_SHIFT_EVER) { i = i >> shft; return scheme_make_integer(i);