Programmer Calculator

keyboard: 0–9 a–f ( ) & | ^ ~ < > + − * / % ⏎ ⌫ esc
flags C V Z N

Exercises —

Each group starts with a primer; load sets up the calculator, answer checks, and a ticked exercise is tucked away.

Help

The display

The HEX, DEC, OCT and BIN readouts show one value four ways. Tap one to type in that base; the highlighted readout is the one you are typing into, and digits that do not exist in that base are greyed out. The ⧉ icon copies the value with a 0x, 0o or 0b prefix.

8 · 16 · 32 · 64 sets the word size, and every result wraps to that many bits. unsigned / signed changes how the decimal row reads the same bits: signed uses two's complement, and ÷, mod and right shifts become arithmetic.

Tap any bit in the bit grid to flip it. The label above the top bit shows what that bit is worth, +2ⁿ⁻¹ unsigned or −2ⁿ⁻¹ signed, and lights while the bit is set. The ascii line shows each byte as a character, and the char box loads a character's code point and shows its UTF-8 and UTF-16 encodings.

Flags

The flags describe the last operation, like a CPU status register. Typing a number or tapping bits is not an operation, so it leaves them clear, as a load instruction does on a CPU. They clear when you press AC or change the word size, and they stay put when you switch between signed and unsigned so both readings of a result can be compared.

C
carry or borrow: the unsigned result did not fit the word. For shifts and rotates, the last bit shifted out.
V
overflow: the signed result did not fit the word.
Z
the result was zero.
N
the result has its top bit set.

Keys

AND OR XOR NOR
bitwise operations between two values.
<< >>
shift the value one bit left or right.
X<<Y X>>Y
shift by a count: enter the value, press the key, enter the count, press =.
NOT NEG
invert every bit; two's-complement negate.
RoL RoR
rotate one bit left or right; the bit that wraps around goes to C.
mod
remainder of a division.
flip8 flip16
reverse the byte order, or the 16-bit word order (endianness).
( )
group a sub-expression; the line above the rows shows what is still pending.
⌫ AC
delete the last digit; clear everything. Dividing by zero shows an error that AC clears.

On a phone the keypad and the operations are two pages: swipe between them, or tap keypad | ops.

Keyboard

0–9 a–f digits · ( ) · & AND · | OR · ^ XOR · ~ NOT · < > shift by a count · + - * / · % mod · Enter or = · Backspace · Esc AC

Exercises

Work through the groups in order; every function on the keypad is covered at least once, and the capstones chain them together the way real register, encoding and decoding problems do. Each group opens with a primer that explains the concept and gives an example to try, then its list of exercises. load sets the calculator to the starting value and word size, and answer reveals the worked solution. Tick an exercise when it is done: it is tucked away and the group's summary counts it, and a fully ticked group is tucked away too. show N done brings them back to review or untick, and hide collapses the whole section. Ticks are saved on this device only.

Learn more

Two companion pages live alongside the calculator: a printable two's complement tutorial (PDF) and the Bit Lab, which builds an ALU and its flags from gates you can tap. The primers of the related exercise groups link straight to the relevant page.

App

Everything works offline once it has loaded. theme cycles auto → light → dark and is remembered. Install it from the browser menu, or with the install app button when it appears, to get a full-screen app with its own icon.