Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
;; Logical / unsigned shift right in Clojure (>>> operator in Java)
;; Algorithm from
(defn logical-shift-right [n s]
(if (neg? n)
(bit-or (bit-shift-right (bit-and n 0x7fffffff) s)
(bit-shift-right 0x40000000 (dec s)))
(bit-shift-right n s)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.