@kszongic/bitmask-cli
v1.0.0
Published
Zero-dependency CLI for bitwise operations: AND, OR, XOR, NOT, shifts, and bit manipulation
Maintainers
Readme
@kszongic/bitmask-cli
Zero-dependency CLI for bitwise operations. AND, OR, XOR, NOT, shifts, and bit manipulation — right from your terminal.
Install
npm i -g @kszongic/bitmask-cliUsage
bitmask and 0xFF 0x0F # 15 (0b00001111)
bitmask or 0b1010 0b0101 # 15 (0b00001111)
bitmask xor 12 7 # 11 (0b00001011)
bitmask not 0 # -1 (0b11111111111111111111111111111111)
bitmask lshift 1 8 # 256 (0b100000000)
bitmask rshift 256 4 # 16 (0b10000)
bitmask set 0 3 # 8 (0b00001000)
bitmask clear 0xFF 4 # 239 (0b11101111)
bitmask toggle 0b1010 1 # 8 (0b00001000)
bitmask check 0xFF 7 # 1 (bit 7 is set)
bitmask bits 255 # 11111111
bitmask popcount 0xFF # 8
bitmask mask 8 # 255 (0b11111111)Numbers can be decimal, hex (0x), octal (0o), or binary (0b).
Operations
| Command | Description |
|---------|-------------|
| and a b | Bitwise AND |
| or a b | Bitwise OR |
| xor a b | Bitwise XOR |
| not a | Bitwise NOT (32-bit) |
| lshift a n | Left shift |
| rshift a n | Unsigned right shift |
| set a bit | Set bit at position |
| clear a bit | Clear bit at position |
| toggle a bit | Toggle bit |
| check a bit | Check if bit is set |
| bits a | Binary representation |
| popcount a | Count set bits |
| mask n | Generate n-bit mask |
License
MIT © kszongic
