function/macro | since v0.0-927 | clojure.core/bit-flip | Edit |
(bit-flip x n)
Flip bit at index n
. Same as x ^ (1 << y)
in JavaScript.
Bits can be entered using radix notation:
(bit-flip 2r1111 2)
;;=> 11
;; 11 = 2r1011
Same numbers in decimal:
(bit-flip 15 2)
;;=> 11
Flip bit at index n
(defn bit-flip
[x n]
(cljs.core/bit-flip x n))
(core/defmacro ^::ana/numeric bit-flip [x n]
(core/list 'js* "(~{} ^ (1 << ~{}))" x n))