bitwise-bit-count(3scm)
π NAME π
bitwise-bit-count β population count, bestie β¨
okay so this is the bitwise-bit-count(3scm) page from the Scheme Programmer's Manual, and we're gonna get you comfy with it π
π LIBRARY π
the imports are giving very R6RS, no cap:
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
πͺ SYNOPSIS πͺ
(bitwise-bit-count ei)
(fxbit-count fx)
π DESCRIPTION π
If the argument is non-negative, this procedure returns the number of 1 bits in its two's complement representation. slay.
Otherwise, it returns the result of this computation, exactly:
(bitwise-not (bitwise-bit-count (bitwise-not ei)))
like, that's the whole vibe π¦
π RETURN VALUES π
Returns a single exact integer object. one exact integer object, periodt π
β¨ EXAMPLES β¨
these examples are iconic, honestly:
(bitwise-bit-count #b1)
=> 1
(bitwise-bit-count #b1000)
=> 1
(bitwise-bit-count #b1001)
=> 2
(bitwise-bit-count #b-1001)
=> -2
π οΈ APPLICATION USAGE π οΈ
This procedure is used to compute the Hamming distance. It's also used in Hash Array Mapped Tries and other applications. iykyk π
π§© COMPATIBILITY π§©
This procedure is new in R6RS. SRFI-151 has the similar procedure bit-count.
π ERRORS π
This procedure can raise exceptions with the following condition types:
π &assertion (R6RS) π
The wrong number of arguments was passed or an argument was outside its domain. For fxbit-count the argument must be a fixnum. yes, that includes the fixnum vibe check π₯
π SEE ALSO π
π STANDARDS π
R6RS π
π°οΈ HISTORY π°οΈ
This procedure can be implemented with the popcount procedure in x86-64 processors. This instruction appeared even in some early computers like the IBM Stretch (1961). history class but make it bits π
π«Ά AUTHORS π«Ά
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/. π
xoxo, your Scheme bestie π«Ά β source/version: Scheme Programmer's Manual, bitwise-bit-count(3scm), dated 2021-03-08. bye bestie! π
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2021 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms