Bits, bytes and their symbols

A bit is a single 0 or 1, and a byte is a group of 8 bits; both are introduced on Number Systems and Data Representation. Everything on this page builds on one conversion:

1\ \text{byte} = 8\ \text{bits}

Standards also use the word octet for exactly 8 bits, because some very old machines had bytes of other sizes. Network RFCs (Requests for Comments, the documents that define internet protocols) say octet; everyone else says byte. The standard for units in information technology, IEC 80000-13, recommends using the name byte and the symbol B only for 8-bit bytes.

Letter case carries meaning in unit symbols, so it matters how you write them:

Symbol Means Typical use
b, bit bit line rates: 100 Mbit/s, also written 100 Mbps
B byte (8 bits) file and disk sizes: 4 GB, 512 MiB
k kilo, 1000 always lowercase: kB, kbit/s, kW
K (no i) usually 1024, by old convention memory specifications: "KB" meaning 1024 bytes
Ki, Mi, Gi, Ti binary prefixes: powers of 1024 KiB, MiB, GiB, TiB in operating systems and tools

Decimal prefixes: powers of 1000

The International System of Units, the metric system that science and trade use worldwide, puts a prefix in front of a unit to scale it by a power of ten. A decimal prefix such as kilo, mega or giga multiplies by exactly 10^{3}, 10^{6} or 10^{9}. A kilometer is 1000 meters, a kilowatt is 1000 watts, and a kilobyte is 1000 bytes. The prefixes go up in steps of 1000:

Prefix Symbol Factor IT example
kilo k 10^{3} a 75 kB email
mega M 10^{6} a 100 Mbit/s office line
giga G 10^{9} a 10 Gbit/s switch port
tera T 10^{12} a 4 TB hard disk
peta P 10^{15} a data lake
exa, zetta, yotta E, Z, Y 10^{18}, 10^{21}, 10^{24} worldwide data volumes
ronna, quetta R, Q 10^{27}, 10^{30} added in 2022; not yet needed for data

The same system has prefixes for small quantities, and IT uses them all the time for time: a millisecond (ms) is 10^{-3} seconds, a microsecond (µs) 10^{-6} and a nanosecond (ns) 10^{-9}. A network round trip across Europe takes tens of milliseconds, a read from a fast solid-state drive tens of microseconds, and a read from memory about a hundred nanoseconds.

The official definition is strict: the BIPM (International Bureau of Weights and Measures) brochure The International System of Units (9th edition) states that these prefixes mean powers of ten only, and that one kilobit is 1000 bits, not 1024. Disk manufacturers and network equipment follow that rule.

Binary prefixes: powers of 1024

Computer memory is built in powers of two, because an address of n bits can point to 2^{n} places. And 2^{10} = 1024 happens to be close to 1000. For decades people therefore said "kilobyte" for 1024 bytes, and "megabyte" for 1024^{2}. That was convenient until the numbers got big enough for the difference to matter.

The International Electrotechnical Commission (IEC) solved the ambiguity in 1998 with a separate set of names. A binary prefix multiplies by a power of 2^{10} = 1024; its name ends in "bi" (for binary) and its symbol in "i". A kibibyte (KiB) is therefore exactly 1024 bytes, a mebibyte (MiB) is 1024^{2} = 1{,}048{,}576 bytes, and a gibibyte (GiB) is 1024^{3} bytes. The prefixes are defined in IEC 80000-13; its 2025 edition added new binary prefixes for even larger multiples.

Binary prefix Factor Decimal counterpart Binary is larger by
kibi (Ki) 2^{10} = 1{,}024 kilo, 10^{3} 2.4%
mebi (Mi) 2^{20} = 1{,}048{,}576 mega, 10^{6} 4.9%
gibi (Gi) 2^{30} = 1{,}073{,}741{,}824 giga, 10^{9} 7.4%
tebi (Ti) 2^{40} tera, 10^{12} 10.0%
pebi (Pi) 2^{50} peta, 10^{15} 12.6%
exbi (Ei) 2^{60} exa, 10^{18} 15.3%

The last column is \frac{2^{10k}}{10^{3k}} - 1 for step k: each step multiplies the ratio by another 1.024, so the gap keeps growing. At kilo it is a rounding error; at tera it is a tenth.

Worked example: the "missing" space

Amara Okafor at the Kestrel Energy service desk gets a ticket: a new "1 TB" drive shows up as 931 GB in Windows. Is part of the disk broken?

  1. The manufacturer uses decimal prefixes: 1 TB is 10^{12} = 1,000,000,000,000 bytes.
  2. Windows File Explorer divides by 2^{30} but labels the result "GB".
  3. 10^{12} / 2^{30} \approx 931.32, so it shows about 931 "GB", which are really 931 GiB.
  4. No space is missing. Both numbers describe the same 1,000,000,000,000 bytes, which is 10^{12} / 2^{40} \approx 0.9095 TiB.
disk_bytes = 1 * 10 ** 12           # a "1 TB" drive
print(f"{disk_bytes / 2 ** 30:.2f} GiB")
print(f"{disk_bytes / 2 ** 40:.4f} TiB")
print(16 * 2 ** 30, "bytes in 16 GiB")
print(f"{(2 ** 40 / 10 ** 12 - 1):.1%} gap at tera/tebi")
931.32 GiB
0.9095 TiB
17179869184 bytes in 16 GiB
10.0% gap at tera/tebi

Who uses which

  • Decimal: disk and SSD capacities, network and line rates, most cloud storage and transfer price lists (check the provider's definition).
  • Binary: RAM. Memory standards from JEDEC, the semiconductor industry's standards body, define "kilo" for memory capacity as 1024, so a "16 GB" memory module holds 16 GiB: 17,179,869,184 bytes.
  • Binary with decimal symbols: Windows, which shows GiB values with the label "GB".
  • Your choice: Linux tools. df -h and ls -lh print sizes in powers of 1024 with short suffixes such as 932G (they round up, like numfmt below); df -H uses powers of 1000. numfmt converts in both directions:
numfmt --to=iec-i --suffix=B 1000000000000
numfmt --to=iec-i --suffix=B --round=nearest 1000000000000
numfmt --from=iec-i 16Gi
932GiB
931GiB
17179869184

Note the first line: numfmt rounds away from zero by default, so 931.32 GiB becomes "932GiB". Tools differ in rounding as well as in prefixes; when exact numbers matter, ask for bytes. The storage page shows how this plays out for disk capacity.

Bit rates and transfer times

The bit rate of a connection is the number of bits it carries per second, written bit/s or bps. Line rates always use decimal prefixes: 1 Gbit/s is exactly 10^{9} bits per second. How bandwidth, throughput and latency relate is explained in What Is a Network?; here is the arithmetic.

The time to move a file is its size divided by the speed, once both are in the same unit. Sizes are in bytes and speeds in bits, so multiply the size by 8 first:

t = \frac{\text{size in bytes} \times 8}{\text{bit rate in bit/s}}

Worked example: a 50 GB backup

Hamid Rahimi, Kestrel Energy's database administrator, needs to copy a 50 GB database backup to another site over a 100 Mbit/s line.

  1. Size in bits: 50 \times 10^{9} bytes \times\ 8 = 4 \times 10^{11} bits.
  2. Speed in bits per second: 100 \times 10^{6} = 10^{8} bit/s.
  3. Divide: 4 \times 10^{11} / 10^{8} = 4000 seconds.
  4. Convert: 4000 s is 66 minutes and 40 seconds, so 1 h 6 min 40 s.
size_bytes = 50 * 10 ** 9           # 50 GB backup
link_bits_per_s = 100 * 10 ** 6     # 100 Mbit/s
seconds = size_bytes * 8 / link_bits_per_s
h, rest = divmod(int(seconds), 3600)
m, s = divmod(rest, 60)
print(seconds, f"= {h} h {m} min {s} s")
4000.0 = 1 h 6 min 40 s

That is the theoretical minimum. In practice protocol headers, acknowledgments, encryption and other traffic take a share of the line, so plan with an efficiency factor. With 2 TB of nightly backups over a 1 Gbit/s link that delivers 80% of its rate:

size_bytes = 2 * 10 ** 12           # 2 TB of backups
rate = 1 * 10 ** 9 * 0.80           # 1 Gbit/s at 80% efficiency
seconds = size_bytes * 8 / rate
h, rest = divmod(int(seconds), 3600)
m, s = divmod(rest, 60)
print(f"{seconds:,.0f} s = {h} h {m} min {s} s")
20,000 s = 5 h 33 min 20 s

If the backup window is from 01:00 to 06:00, five hours, this does not fit. You now know by how much, and can choose between a faster link, incremental backups or a longer window before the first backup fails.

Dimensional analysis

Most unit mistakes disappear if you treat units as part of the number. Dimensional analysis means writing the units next to every value in a calculation and cancelling them like factors in a fraction. A conversion factor such as \frac{8\ \text{bit}}{1\ \text{B}} equals 1, so multiplying by it changes the unit but not the amount. If the unit that remains at the end is not the one you want, the calculation is wrong, whatever the number says.

Worked example: a year of meter data

Kestrel Energy has about 400,000 smart meters. Each sends a reading every 15 minutes (96 per day), and each reading takes 16 bytes in the database. How much storage does one year of readings need?

400{,}000\ \cancel{\text{meters}} \times \frac{96\ \cancel{\text{readings}}}{\cancel{\text{meter}} \cdot \cancel{\text{day}}} \times \frac{16\ \text{B}}{\cancel{\text{reading}}} \times \frac{365\ \cancel{\text{days}}}{\text{year}} = 2.24256 \times 10^{11}\ \frac{\text{B}}{\text{year}}
  1. Meters cancel against "per meter", readings against "per reading", days against "per day".
  2. What is left is bytes per year: the unit we wanted, which is a good sign.
  3. Multiply the numbers: 4 \times 10^{5} \times 96 \times 16 \times 365 = 2.24256 \times 10^{11}.
  4. That is 224.3 GB, or 208.9 GiB, before indexes, replicas and backups.
meters = 400_000
readings_per_day = 96               # one every 15 minutes
bytes_per_reading = 16
per_year = meters * readings_per_day * bytes_per_reading * 365
print(f"{per_year:,} bytes = {per_year / 10 ** 9:.1f} GB = {per_year / 2 ** 30:.1f} GiB")
224,256,000,000 bytes = 224.3 GB = 208.9 GiB

The same habit checks storage performance. A disk that delivers 20,000 IOPS (input/output operations per second) with 4 KiB blocks moves 20{,}000\ \frac{\text{op}}{\text{s}} \times 4096\ \frac{\text{B}}{\text{op}} = 81,920,000 B/s: 81.92 MB/s, or 78.125 MiB/s. The relation between IOPS, block size and throughput is explained in Storage Fundamentals.

Two conversion chains. Top: bits divided by 8 gives bytes, then divide by 1000 for each step to kB, MB, GB and TB. Bottom: bytes divided by 1024 for each step to KiB, MiB, GiB and TiB. Going to the left, multiply instead. bits bytes kB MB GB TB bytes KiB MiB GiB TiB ÷ 8 ÷ 1000 ÷ 1000 ÷ 1000 ÷ 1000 ÷ 1024 ÷ 1024 ÷ 1024 ÷ 1024 binary: to the right: divide · to the left: multiply
The conversion chains for decimal prefixes (top) and binary prefixes (bottom). Both start from the same number of bytes.

Power and energy: kW and kWh

Data centers, UPS (uninterruptible power supply) systems and energy bills use two units that look alike but measure different things. Power, in watts (W) or kilowatts (kW), is a rate: how fast energy is used at this moment. Energy is an amount: power kept up over time. The kilowatt-hour (kWh) is the energy used by a load of 1 kW running for one hour; it is the unit on every Dutch electricity bill and on Kestrel Energy's smart meters.

E = P \cdot t \qquad 1\ \text{kWh} = 1000\ \text{W} \times 3600\ \text{s} = 3.6 \times 10^{6}\ \text{J}

Read it as: energy equals power times time. A 2 kW heater running for 3 hours uses 2 \times 3 = 6 kWh, and so does a 6 kW heater running for 1 hour. The joule (J), one watt for one second, is the base unit of energy; kWh is simply a more practical size.

Worked example: what a server costs per year

  1. A server draws 450 W on average: 0.45 kW.
  2. A year has 24 \times 365 = 8760 hours.
  3. Energy: 0.45\ \text{kW} \times 8760\ \text{h} = 3942\ \text{kWh}. The hours cancel against the "h" in kWh, and kWh is left: the right unit.
  4. At €0.25 per kWh that is 3942 \times 0.25 = 985.50 euros a year, before cooling.
# Energy (kWh) = power (kW) x time (h)
server_watts = 450
hours = 24 * 365
kwh = server_watts / 1000 * hours
print(f"{kwh:,.0f} kWh per year, {kwh * 0.25:,.2f} euros at 0.25 per kWh")
3,942 kWh per year, 985.50 euros at 0.25 per kWh

Cooling and power distribution add to that; the ratio between the total facility energy and the IT energy is the power usage effectiveness (PUE). Power ratings for UPS and power distribution also come in kVA, which is not the same as kW; see power budgets.

Common unit mistakes

Most unit errors in IT are one of a handful of patterns. Each one is caught by writing the units down, as in the examples above.

Mistake How big the error is Check
bits taken for bytes, or the other way round a factor of 8 is the letter b or B?
GB taken for GiB 7.4% (10.0% for TB/TiB) does the tool divide by 1000 or by 1024?
kW taken for kWh not a factor at all: a different quantity is it a rate (power, kW) or an amount (energy, kWh)?
line rate taken for usable throughput a few percent on a good link, far more on a busy one plan with a measured efficiency, not the nominal rate
mixing milliseconds and microseconds a factor of 1000 ms is 10^{-3} s, µs is 10^{-6} s