FM Field Manual smhansen.dev

FM 6-03 Chapter 6 · Numbers and units

Bitwise calculator

AND, OR, XOR, NOT, shifts and rotates at 8 to 64 bits, signed or unsigned, with popcount, masks and a bit grid.

Local only Runs in your browser. Nothing you enter leaves this page.

Width
Read as
A
195 0xc3 1100 0011 popcount 4 · leading zeros 0 · trailing zeros 0
B
170 0xaa 1010 1010 popcount 4 · leading zeros 0 · trailing zeros 1

Results · 8 bit unsigned

A AND B
130 0x82 1000 0010
A OR B
235 0xeb 1110 1011
A XOR B
105 0x69 0110 1001
A AND NOT B
65 0x41 0100 0001
NOT A
60 0x3c 0011 1100
NOT B
85 0x55 0101 0101
A << 2
12 0x0c 0000 1100
A >> 2, logical
48 0x30 0011 0000
A >>> 2, logical
48 0x30 0011 0000
A rotate left 2
15 0x0f 0000 1111
A rotate right 2
240 0xf0 1111 0000
A AND B · bits 7 to 0
76543210 A 11000011B 10101010= 10000010

Masks and single bits

Mask
113 0x71 0111 0001
A AND mask
0x41 some mask bits set in A
Bit 7 of A
1, set
A, set bit 7
195 0xc3
A, clear bit 7
67 0x43
A, toggle bit 7
67 0x43

Operands are decimal or carry 0x, 0b or 0o, and may be negative. They are cut to the chosen width as two's complement, so -1 and 255 are the same 8-bit pattern. With Signed, decimals are read as two's complement and >> is arithmetic (copies the sign bit); >>> always shifts in zeros. Shifting by the width or more clears every bit (JavaScript and x86 would take the count modulo 32 or 64). Mask positions count from bit 0, the least significant, and take ranges like 4-7.

  • No entry in this manual matches “”.

↑ ↓ move · Enter open · Esc close