bit-test

function/macrosince v0.0-927 clojure.core/bit-testEdit
(bit-test x n)

Details:

Test bit at index n. Returns true if 1, and false if 0. Same as (x & (1 << y)) != 0 in JavaScript.


Examples:

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

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

Macro code @ clojurescript:src/main/clojure/cljs/core.cljc
(core/defmacro bit-test [x n]
  (bool-expr (core/list 'js* "((~{} & (1 << ~{})) != 0)" x n)))