Simple types / Numbers / Integer

(def a 5)  ; 0101
(def b 6)  ; 0110

;; and
(def c1 (bit-and a b))          ; c1 is 4 (0100)

;; or
(def c2 (bit-or a b))           ; c2 is 7 (0111)

;; xor
(def c3 (bit-xor a b))          ; c3 is 3 (0011)

;; shift right
(def c4 (bit-shift-right a 1))  ; c4 is 2 (0010)

;; shift left
(def c5 (bit-shift-left b 1))   ; c5 is 12 (1100)

;; bits inversion
(def c6 (bit-not b))            ; c6 is -7 (-111)

(doseq [v [c1 c2 c3 c4 c5 c6]]
  (println v))

;; a single bit can be read and set by index
(println "bit 2 of 5 is" (bit-test a 2))
(println "5 with bit 1 set is" (bit-set a 1))