Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
count number of bits that type is integer. (by F#)
let rec numofbits bitwidth x =
match bitwidth with
|0 -> 0
|_ -> (x &&& 1) + numofbits (bitwidth - 1) (x / 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment