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
(defn flipped-endian-float | |
"Flips the endian order of the supplied byte sequence, and converts | |
the sequence into a float." | |
[bitseq] | |
(Float/intBitsToFloat | |
(reduce + | |
(map-indexed (fn [idx bit] | |
(bit-shift-left | |
(bit-and bit 0xff) | |
(* 8 idx))) | |
bitseq)))) | |
(defn flipped-endian-float | |
"Flips the endian order of the supplied byte sequence, and converts | |
the sequence into a float." | |
[bitseq] | |
(->> bitseq | |
(map-indexed (fn [idx bit] | |
(bit-shift-left | |
(bit-and bit 0xff) | |
(* 8 idx)))) | |
(reduce +) | |
(Float/intBitsToFloat))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment