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