Skip to content

Instantly share code, notes, and snippets.

@viperscape
Last active August 29, 2015 13:56
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 viperscape/9134465 to your computer and use it in GitHub Desktop.
Save viperscape/9134465 to your computer and use it in GitHub Desktop.
returns map of which bits where flagged
(defn- bits-lit [b]
"cerates seq of bits that are flagged"
(map #(bit-and b (bit-shift-left 1 %)) (range 8)))
(bits-lit 23) ;;(1 2 4 0 16 0 0 0)
(map pos? (bits-lit 23)) ;; (true true true false true false false false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment