Skip to content

Instantly share code, notes, and snippets.

@viperscape
Created February 22, 2014 22:48
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/9163554 to your computer and use it in GitHub Desktop.
Save viperscape/9163554 to your computer and use it in GitHub Desktop.
int32 to 4 bytes, which could be used to send size of a following datagram, like a bytes header
(let [i 128900, b (map #(unchecked-byte(bit-shift-right i (* % 8))) (range 0 4))]
{i (reduce +(map #(bit-shift-left (bit-and %1 255) (* %2 8)) b (range 0 4)))})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment