diff options
author | Mark Oteiza <mvoteiza@udel.edu> | 2017-09-30 14:14:12 -0400 |
---|---|---|
committer | Mark Oteiza <mvoteiza@udel.edu> | 2017-09-30 14:16:18 -0400 |
commit | 185f33340680d918a95ff704a8f7e2d9e1a6f0ca (patch) | |
tree | af80fe1f744c467325c54a0361d6f1309bbe2855 /doc/lispref/numbers.texi | |
parent | 20a09de953f437109a098fa8c4d380663d921481 (diff) | |
download | emacs-185f33340680d918a95ff704a8f7e2d9e1a6f0ca.tar.gz |
Add logcount (Bug#22689)
* doc/lispref/numbers.texi (Bitwise Operations): Add documentation.
* etc/NEWS: Mention.
* src/data.c (logcount32, logcount64): New functions.
(logcount): New Lisp function.
(syms_of_data): Declare it.
* test/src/data-tests.el (data-tests-popcnt, data-tests-logcount): New
test.
Diffstat (limited to 'doc/lispref/numbers.texi')
-rw-r--r-- | doc/lispref/numbers.texi | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 3fdc94169bd..5058063af4d 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi @@ -1107,6 +1107,19 @@ bit is one in the result if, and only if, the @var{n}th bit is zero in @end example @end defun +@cindex popcount +@cindex Hamming weight +@cindex counting set bits +@defun logcount integer +This function returns the @dfn{Hamming weight} of @var{integer}: the +number of ones in the binary representation of @var{integer}. + +@example +(logcount 42) ; 42 = #b101010 + @result{} 3 +@end example +@end defun + @node Math Functions @section Standard Mathematical Functions @cindex transcendental functions |