Created
January 11, 2012 00:22
-
-
Save zentrope/1592151 to your computer and use it in GitHub Desktop.
bytes->int clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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