---
title: "bitmask"
type: concept
related: [Vector, Bitmask]
source: https://www.jemoka.com/posts/kbhbitmask/
confidence: high
status: active
---

bitmasking is a very helpful to create bit vectors.
| with a 1-mask is useful to turning things on &amp; with a 0-mask is useful to turning things off (bitvector &amp; not(1-mask)) | is useful for set unions &amp; is useful for intersections of bits ^ is useful for flipping isolated bits: 0 is bit preserving, 1 is bit negating ~ is useful for flipping all bits
