hex.count_bitsΒΆ

dst[:small_n] = x[:n].#on-bits

x is hex.vec n, and dst is hex.vec small_n.
small_n (it’s 2 for 16-255 bit-numbers) is the smallest number of bits that can hold the number n: ((#(n*4))+3)/4

SignatureΒΆ

def count_bits n, dst, x { ... }

Defined in hex/math_basic.fj β€” lines 83–86 (view on GitHub).

ComplexityΒΆ

  • Time: n(2.27@-1)

  • Space: n(3.5@+135)    // on 16-255 bit-numbers. (a bit bigger on bigger numbers).

See the complexity glossary for what @, w, dw, dbit, n mean.

SourceΒΆ

Depends onΒΆ

Used byΒΆ

Example usesΒΆ


← Previous: hex.add_count_bits Next: hex.inc1 β†’