Skip to content

Instantly share code, notes, and snippets.

@zentrope
Created January 11, 2012 00:22
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 zentrope/1592151 to your computer and use it in GitHub Desktop.
Save zentrope/1592151 to your computer and use it in GitHub Desktop.
bytes->int clojure
;; Surely I can do better than this.
(defn- ^BigInteger bytes->int
[^bytes bytes & {:keys [little-endian]
:or {little-endian true}}]
(let [b (if little-endian (reverse bytes) bytes)]
(->> b
(cons (byte 0))
(byte-array)
(biginteger))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment