Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Created March 26, 2012 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsakamoto/2204346 to your computer and use it in GitHub Desktop.
Save jsakamoto/2204346 to your computer and use it in GitHub Desktop.
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