aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorPaul Eggert2017-09-30 15:36:52 -0700
committerPaul Eggert2017-09-30 15:38:14 -0700
commit8136df6a8cbf071266eb38f5baef005f4e9241a3 (patch)
tree4ade7520c5be858be40b7939a0338e4a48288c85 /doc
parentd247e1d30abcb77665f829ca98a5bdef69ff4bc3 (diff)
downloademacs-8136df6a8cbf071266eb38f5baef005f4e9241a3.tar.gz
emacs-8136df6a8cbf071266eb38f5baef005f4e9241a3.zip
Make logcount act like CL on negative arg
Behaving like Common Lisp is less likely to lead to surprises, as it yields the same answers on 32- vs 64-bit machines. * doc/lispref/numbers.texi (Bitwise Operations): Document behavior on negative integers. * src/data.c (Flogcount): Behave like Common Lisp for negative arguments. * test/src/data-tests.el (data-tests-popcnt) (data-tests-logcount): Test negative args too.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/numbers.texi7
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index 5058063af4d..be74b0c6111 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -1113,9 +1113,14 @@ bit is one in the result if, and only if, the @var{n}th bit is zero in
1113@defun logcount integer 1113@defun logcount integer
1114This function returns the @dfn{Hamming weight} of @var{integer}: the 1114This function returns the @dfn{Hamming weight} of @var{integer}: the
1115number of ones in the binary representation of @var{integer}. 1115number of ones in the binary representation of @var{integer}.
1116If @var{integer} is negative, it returns the number of zero bits in
1117its two's complement binary representation. The result is always
1118nonnegative.
1116 1119
1117@example 1120@example
1118(logcount 42) ; 42 = #b101010 1121(logcount 43) ; 43 = #b101011
1122 @result{} 4
1123(logcount -43) ; -43 = #b111...1010101
1119 @result{} 3 1124 @result{} 3
1120@end example 1125@end example
1121@end defun 1126@end defun