Learning LabExplorable explanations
← All artifacts
Computer Systems

The Interactive Byte

Toggle eight bits and watch one number speak binary, decimal, hex, octal, and ASCII at once. Then play with AND, OR, XOR, NOT, and shifts computed column by column.

bitsbytesbinarybitwisecomputer-systems
LiveInteractive · drag, toggle, run it
Computer Systems · Foundations

The Interactive Byte

Everything a computer stores is bits, and they travel in groups of eight called bytes. Toggle the eight bits below and the same value shows up at once as binary, decimal, hex, octal, and a character. Then take two bytes into the bitwise playground and see AND, OR, XOR, NOT, and shifts worked out column by column.

The byte

Click a bit to flip it, or tab to it and press space or enter. Each bit owns a place value, a power of two. The byte is just the sum of the place values whose bit is 1.

64 + 1 = 65
Binary
01000001
Unsigned decimal
65
Hexadecimal
0x41
Octal
0o101
ASCII
'A'
in the printable range 32 to 126
0x
Each hex digit is exactly four bits, one nibble:
high nibble
0100=4
low nibble
0001=1
Presets:

A bit is one binary digit, a 0 or a 1. Eight of them make a byte, so a byte holds 2^8 = 256 distinct values, the integers 0 through 255. Hex is convenient because one hex digit covers exactly four bits, so a byte is always two clean hex digits with no leftover.

Bitwise playground

Two operands you can edit bit by bit. Pick an operation and read the result computed one column at a time. Every result is masked back to eight bits, so what you see is always a byte.

Operand A
Operand B
A
11001010
0xCA
B
01101100
0x6C
=
01001000
0x48
202 & 108 = 72 = 0x48 = 01001000
1 only when both inputs are 1

These are real JavaScript bitwise operators. JS evaluates them on 32-bit integers, so the result is masked with & 0xff to keep the display a single byte. AND with a mask clears bits you do not want; OR sets flags; XOR toggles them; a left shift by n multiplies by 2^n until bits fall off the top.

Place value i contributes 2^i when its bit is 1.