# bitwise is a register dump calculator for the terminal

> bitwise shows a number in every base at once, lets you flip individual bits with the cursor, and evaluates C-style expressions with C's own precedence, and the reason it exists is that reading a register dump in your head is miserable.

**mellowcandle/bitwise** — Terminal based bit manipulator in ncurses

- Repository: https://github.com/mellowcandle/bitwise
- Stars: 723 · Forks: 31
- Language: C
- License: GPL-3.0
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/mellowcandle-bitwise

## Every base, side by side, in one screen

bitwise is a multi-base interactive calculator and bit manipulator for the terminal, and the stated audience is low level hackers, kernel developers and device driver developers, described as anyone who spends their day staring at a register dump wondering which bit is set. The design goal is that you never convert anything by hand. You get decimal signed and unsigned, hexadecimal, octal and binary side by side, and editing a number in any field makes the rest follow. On top of that there is individual bit manipulation, so you can walk the binary row and toggle bits with the cursor, and a C-style expression calculator covering the bitwise and arithmetic operators with C's precedence. The bit width is selectable at 8, 16, 32 or 64 bits and switchable on the fly. The extras listed are human-readable sizes in either IEC or SI, IPv4 in both byte orders, ASCII and Radix64, and the tool is written in C with an ncurses interface, which is why it starts instantly and runs anywhere a terminal does.

## One-shot conversions need no installation gymnastics

Passing a number gives you every representation at once, and a whole expression is evaluated first if that is what you passed. The base is detected from the prefix of the input, with 0x or 0X for hexadecimal, a leading 0 for octal, b for binary, and everything else treated as decimal. IPv4 addresses are parsed as well and reported in both network and reversed byte order. The option set is short.

```sh
bitwise -- '-5'
```

That last line is there for a real reason, and the readme explains it: an expression starting with a minus sign would be taken for a command line option, so it has to be separated with the double dash. The other options cover the interactive mode, which is the default when there is no input, the bit width through the -w flag with b for byte, w for word, l for long and d for double and l as the default, the -s flag to print sizes using the SI standard rather than the default IEC, --no-color to start without colour support, and the usual version and help flags. The interactive mode starts when no parameters are passed or with the -i flag, and F1 brings up the help screen.

## The expression evaluator is a C subset, and the omissions are deliberate

The expression syntax is a subset of C plus Verilog's bit select, and the operators are listed in precedence order, tightest binding first. Unary !, ~, - and + bind tightest and are right associative, then multiplication, division and modulo, then addition and subtraction, then the shifts, then &, then ^, and then |. Parentheses group as usual and multiplication can be implicit, so 2(3) and (2)(3) both give 6. The readme is explicit that this is the same ordering a C compiler uses, so an expression lifted out of source evaluates to the same thing here. There is one difference from C, which is that &=, ^= and |= are accepted but there is nothing to assign to, so they evaluate exactly like &, ^ and |. And there is a list of what is not supported, namely comparison and equality with <, >, <=, >=, == and !=, logical && and ||, the ternary ?:, and exponentiation. The practical consequence is that you can evaluate masks and shifts and arithmetic but not conditions, which is the right scope for the tool and a real limit if you expected a general calculator.

## Verilog bit select is the feature that makes it feel like a hardware tool

Fields can be pulled out with Verilog's notation, the same way a datasheet writes them, which is a small idea with a large effect on readability.

```
bitwise '0x875423[31:23]'
bitwise '0x875423[15]'
```

The bracketed form selects the bits from msb down to lsb, or a single bit with one index, and the readme says the field comes back in the result. This is what separates bitwise from a base converter with a bit grid, because in register work the interesting question is almost never the whole word, it is a particular field, and the datasheet notation is the notation engineers already read. The expression calculator handles the arithmetic around it, so you can write a shifted and masked expression and read the field out of the same screen.

## Where bitwise does not fit

Three limits are worth naming. The first is that this is an application, not a library or a filter, so it does not slot into a shell pipeline the way a conversion utility with a filter mode would, and the interactive mode is the reason it exists. The second is the expression evaluator's blind spot, since the missing comparison and logical operators rule out using it to check conditions, and the C subset stops there. The third is the width masking, and the readme puts a warning on it: when changing the bit width, the number is masked with the new width, so you might lose precision, use with care. That is a genuine footgun in a tool whose whole purpose is precision, and it is worth knowing that narrowing a 64-bit value to 8 bits in the interface silently drops the rest.

## Conclusion

bitwise suits a kernel or driver developer who keeps a hex dump open in another window and wants the same value in binary, octal, IPv4 order and a human-readable size at once, and it suits anyone who works out masks mentally and would rather not. It is the wrong tool if you want a scripting library, since this is a curses application rather than something you call from a shell pipeline, and it is the wrong choice if your work is symbolic, because the expression evaluator deliberately omits comparison, logical and, and the ternary operator. Before using it, decide whether you need the interactive mode or the one-shot command line mode, because the bit width masks the value when you change it and can lose precision. The last push was on 2026-09-10 and the current release is v0.70 from 2026-09-05.

## FAQ

### How do I install bitwise?

It is packaged for most distributions, with sudo apt-get install bitwise on Debian and Ubuntu 20.04 or newer, sudo dnf install bitwise on Fedora, zypper install bitwise on openSUSE, sudo xbps-install -S bitwise on Void, an AUR package on Arch, sudo snap install bitwise, nix-env -i bitwise, brew install bitwise on macOS with Homebrew, and on Windows you build from source under mingw or msys2. Older Ubuntu can use the project PPA.

### Which operators does the bitwise expression calculator support?

A subset of C with Verilog bit select: unary !, ~, - and +, then * / %, then + -, then << and >>, then &, then ^, then |, with C's precedence. Comparison and equality, logical && and ||, the ternary operator and exponentiation are not supported, and &=, ^= and |= are accepted but evaluate like &, ^ and |.

### How do I select a bit range with bitwise?

Use Verilog notation, the same way a datasheet writes it. The bracketed form v[msb:lsb] selects the bits from msb down to lsb, and v[bit] selects a single bit, for example bitwise '0x875423[31:23]' and bitwise '0x875423[15]'.

## Sources

- [Issues](https://github.com/mellowcandle/bitwise/issues)
- [License: GPL-3.0](https://github.com/mellowcandle/bitwise/blob/master/LICENSE)
- [mellowcandle/bitwise on GitHub](https://github.com/mellowcandle/bitwise)
- [README](https://github.com/mellowcandle/bitwise/blob/master/README.md)
- [Releases](https://github.com/mellowcandle/bitwise/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/mellowcandle-bitwise
