diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-08-18 15:20:46 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-08-18 15:22:35 -0700 |
commit | 673b1785db4604efe81b8045a9d8ab68936af719 (patch) | |
tree | 0f78d72a7d4eef42b62bcfbaec2627aa04986c80 /doc/lispref/numbers.texi | |
parent | 877cd22f553624b6d7f24141acd134f9cf839259 (diff) | |
download | emacs-673b1785db4604efe81b8045a9d8ab68936af719.tar.gz |
Restore traditional lsh behavior on fixnums
* doc/lispref/numbers.texi (Bitwise Operations): Document that
the traditional (lsh A B) behavior is for fixnums, and that it
is an error if A and B are both negative and A is a bignum.
See Bug#32463.
* lisp/subr.el (lsh): New function, moved here from src/data.c.
* src/data.c (ash_lsh_impl): Remove, moving body into Fash
since it’s the only caller now.
(Fash): Check for out-of-range counts. If COUNT is zero,
return first argument instead of going through libgmp. Omit
lsh code since lsh is now done in Lisp. Add code for shifting
fixnums right, to avoid a round trip through libgmp.
(Flsh): Remove; moved to lisp/subr.el.
* test/lisp/international/ccl-tests.el (shift):
Test for traditional lsh behavior, instead of assuming
lsh is like ash when bignums are present.
* test/src/data-tests.el (data-tests-logand)
(data-tests-logior, data-tests-logxor, data-tests-ash-lsh):
New tests.
Diffstat (limited to 'doc/lispref/numbers.texi')
-rw-r--r-- | doc/lispref/numbers.texi | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 37d2c316490..ee6456b1be1 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi @@ -844,7 +844,9 @@ bits in @var{integer1} to the left @var{count} places, or to the right if @var{count} is negative, bringing zeros into the vacated bits. If @var{count} is negative, @code{lsh} shifts zeros into the leftmost (most-significant) bit, producing a nonnegative result even if -@var{integer1} is negative. Contrast this with @code{ash}, below. +@var{integer1} is negative fixnum. (If @var{integer1} is a negative +bignum, @var{count} must be nonnegative.) Contrast this with +@code{ash}, below. Here are two examples of @code{lsh}, shifting a pattern of bits one place to the left. We show only the low-order eight bits of the binary @@ -913,7 +915,8 @@ is negative. @code{ash} gives the same results as @code{lsh} except when @var{integer1} and @var{count} are both negative. In that case, @code{ash} puts ones in the empty bit positions on the left, while -@code{lsh} puts zeros in those bit positions. +@code{lsh} puts zeros in those bit positions and requires +@var{integer1} to be a fixnum. Thus, with @code{ash}, shifting the pattern of bits one place to the right looks like this: |