You buy a 1 TB drive, plug it into a Windows machine, and File Explorer says 931 GB. Nobody took 69 gigabytes. Almost all of that gap is a units problem: the box counts a gigabyte as 1,000,000,000 bytes, while Windows divides by 1,073,741,824 and still writes "GB". That disagreement comes straight out of binary, so this is binary and bytes explained from the bottom up: what a bit is, why an unsigned byte stops at 255, where hex fits, and how a power of two ended up in your disk size.
The hands-on part is a browser simulator where you flip bits, read values back, and try the same idea on file permissions and subnet masks. Disclosure: I help build it; it is free, runs in the browser, and needs no signup.
A bit is a place value
The Binary Byte Simulator opens in Byte mode: eight tiles in a row, labelled 128, 64, 32, 16, 8, 4, 2 and 1. Click a tile (or press Space on a focused one) to flip it between 0 and 1. The readout shows the decimal value, the hex value, the bit string, and an "as maths" line that adds up the lit tiles.
That line is the whole of binary. Each tile is worth double the one to its right, and a number is the sum of the tiles that are on. The built-in challenges make the point one value at a time. "Make 42" is 32 + 8 + 2. "Make 255" lights all eight, the largest unsigned 8-bit value, which is the range an IPv4 octet and an 8-bit colour channel use. "Make 7" sets the three low bits, and 7 is 8 - 1: in general, 2^n - 1 gives you a value with the lowest n bits set.
Then press Count up and watch. A tile can only show 0 or 1, so when a lit tile has to grow, it flips back to 0 and passes a carry to its left neighbour. The simulator staggers the flips so you can see the carry travel. Let it run past 255 and the byte wraps to 0, the same way an unsigned 8-bit counter overflows. The Shift buttons show the other trick. In Byte mode, shift left multiplies by two modulo 256 (the top bit falls off the end), and shift right is unsigned division by two that drops the remainder.
Test yourself with Predict
Reading is harder than building, so the simulator has a Predict mode for Byte and Permissions. It fills the tiles at random, hides the value, and asks you to type it. A wrong answer does not say "off by 32". It names the bit you missed, in the form "place value 32 is on and worth 32, but your answer leaves it out." That points at the exact tile you misread, instead of a number you have to work backwards from.
The other two modes reuse the same idea where you already meet binary at work. Permissions is nine tiles, read, write and execute for owner, group and other. Three bits hold 0 to 7, exactly one octal digit, which is why chmod 755 is written in octal. Subnet mask is 32 tiles in four octets, with the dotted mask, the prefix length and the usable host count. Put a gap in the run of 1s and it tells you the mask is invalid.
Hex is binary in groups of four
Four bits hold 0 to 15, which is one hex digit (0 to 9, then A to F). So any 8-bit byte fits in two hex digits, with a leading zero when needed: 7 is 0x07. 42 is 0010 1010, and the two halves are 2 and 10, written 0x2A, the value the simulator's hex chip shows. You can check it in Bash:
$ printf '%X\n' 42
2A
$ echo $((2#00101010))
42
That is why hex is everywhere bytes are: MAC addresses, colour codes, memory dumps and hashes are all bytes written two hex digits at a time.
Where 931 GB comes from
Binary addressing makes power-of-two memory sizes convenient, and 2^10 = 1,024 is close to 1,000, so "kilobyte" was historically used for 1,024 bytes as well as for 1,000. Disk makers use the SI meaning, where a terabyte is 10^12 bytes. Western Digital's product pages spell it out: "one terabyte (TB) = one trillion bytes". Windows Explorer divides by 2^30 and still prints "GB":
$ python3 -c 'print(10**12 / 2**30)'
931.3225746154785
Both numbers describe the same bytes. Only the unit differs: in the standard names, 1 kB is 1,000 bytes and 1 KiB is 1,024 bytes, so 1 TB is about 931.32 GiB. The gap grows with each prefix. For the same byte count, the number written in binary units is 2.34% smaller than the decimal one at kilo, 6.87% smaller at giga, and 9.05% smaller at tera. That is why it barely mattered for kilobytes and is hard to miss at terabytes.
The fix exists. In December 1998 the IEC approved separate names for the binary units: kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB). NIST's page on binary prefixes has the full table, and the prefixes now live in IEC 80000-13:2025. The SI prefixes stay decimal only, so a kilobit is 1,000 bits, never 1,024. Windows Explorer never adopted the new names, and Microsoft's Raymond Chen explained why in 2009. Apple's page on how storage capacity is measured says OS X Leopard and earlier reported capacity in binary units. From OS X 10.6 on, Finder uses decimal units, so it shows a figure much closer to the number on the box. Other tools can still use either convention.
See it on your own machine
GNU coreutils can do the conversion both ways. Here it is on Debian 12:
$ numfmt --to=si 1000000000000
1.0T
$ numfmt --to=iec-i --round=nearest 1000000000000
931Gi
Leave off --round=nearest and the same command prints 932Gi, because the default rounds away from zero (numfmt docs).
Your disk tools already disagree with each other in the same way. On the SD card in the Raspberry Pi I tested on, lsblk gives the size in bytes and then in binary units:
$ lsblk -d -b -o NAME,SIZE
NAME SIZE
mmcblk0 31719424000
$ lsblk -d -o NAME,SIZE
NAME SIZE
mmcblk0 29.5G
And df shows both conventions for the same filesystem, -h in powers of 1,024 and -H in powers of 1,000:
$ df -h --output=source,size,used /
Filesystem Size Used
/dev/mmcblk0p2 29G 26G
$ df -H --output=source,size,used /
Filesystem Size Used
/dev/mmcblk0p2 31G 28G
Same bytes, two numbers: df -B1 puts the size at 30,612,148,224 bytes, which is 28.5 GiB or 30.6 GB, and GNU rounds both up. Changing the unit never uses up storage. The filesystem is smaller than the 31,719,424,000-byte card for other reasons: a 512 MiB boot partition and filesystem metadata. On top of that, ext4 reserves 5% of its blocks for root by default, so ordinary users can write even less.
The short version
A bit is a place value. A byte is eight of them: 0 to 255 unsigned, or two hex digits. Units of bytes come in two families, powers of 1,000 on the box and powers of 1,024 in a lot of software, and the gap gets bigger with every prefix. Use Byte mode and Predict in the Binary Byte Simulator to get fluent at reading bits, and the 931 GB on your screen stops looking like missing space.
What is the strangest units mix-up you have run into, GB vs GiB or another one? Tell us in the comments.

Top comments (0)