bit-flip

function/macrosince v0.0-927 clojure.core/bit-flipEdit
(bit-flip x n)

Details:

Flip bit at index n. Same as x ^ (1 << y) in JavaScript.


Examples:

Bits can be entered using radix notation:

(bit-flip 2r1111 2)
;;=> 11
;; 11 = 2r1011

Same numbers in decimal:

(bit-flip 15 2)
;;=> 11

See Also:


Source docstring:
Flip bit at index n
Function code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn bit-flip
  [x n]
  (cljs.core/bit-flip x n))

Macro code @ clojurescript:src/main/clojure/cljs/core.cljc
(core/defmacro ^::ana/numeric bit-flip [x n]
  (core/list 'js* "(~{} ^ (1 << ~{}))" x n))