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ΒΆ
Click to view the macro body
def count_bits n, dst, x {
.zero ((#(n*4))+3)/4, dst
rep(n, i) .add_count_bits ((#(n*4))+3)/4, dst, x+i*dw
}
Depends onΒΆ
Used byΒΆ
Example usesΒΆ
hex.mulinhex/mul.fj
β Previous: hex.add_count_bits
Next: hex.inc1 β