| function/macro | since v0.0-927 | Edit |
(bit-test x n)Test bit at index n. Returns true if 1, and false if 0. Same as (x & (1 << y)) != 0 in JavaScript.
Bits can be entered using radix notation:
(bit-test 2r0100 2)
;;=> true
(bit-test 2r0100 1)
;;=> false
Same numbers in decimal:
(bit-test 4 2)
;;=> true
(bit-test 4 1)
;;=> false
Test bit at index n
(defn ^boolean bit-test
[x n]
(cljs.core/bit-test x n))(core/defmacro bit-test [x n]
(bool-expr (core/list 'js* "((~{} & (1 << ~{})) != 0)" x n)))