2.2 Decimal, binary, octal, and hexadecimal systems

Now that we have a basic grasp ob number systems, let’s dive into some general notations in a computer context.


Bits and Bytes

A binary number only has two possible values: 0 or 1. In a computing context, a single binary digit is called a bit (b), which is the smallest unit of data in a computer.

A byte (B) is a number consisting of 8 bits and is the standard unit for representing a single character in most computers. Since each individual bit in a byte can be either 0 or 1, a byte can have 28 = 256 different values going from 000000002 (010) to 111111112 (25510).

bit (b) = binary digit

Byte (B) = eight bits


Prefixes with bits and bytes

The decimal number uses unit prefixes to address large numbers, this is similarly used with bits and bytes.

  • 210 = 1024 = 1 kilo = 1k
  • 220 = 1048576 = 1 Mega = 1M
  • 230 = 1073741824 = 1 Giga = 1G

This makes grasping large data sizes easier by using standardized prefixes, similar to those in the metric system. These are regularly used in determining and measuring computer memory.

However, you might have noticed that binary prefixes have a base of 2, instead of 10. This difference can cause confusion, thus the IEC (International Electrotechnical Commission) introduced kibibytes (KiB), mebibytes (MiB), gibibytes (GiB), etc., which strictly follow powers of 2.

For example:

  • 1 KB (kilobyte) = 1,000 bytes (SI standard)
  • 1 KiB (kibibyte) = 1,024 bytes (IEC standard)

If you have ever wondered why the storage displayed in your operating system does not match the size you bought, this is why. Hard drive companies market their products with the SI prefix (base 10), while operating systems report sizes using IEC prefixes (base 2).

The discrepancy between SI and IEC units increases with larger storage sizes. Below is the percentage difference between the two:

  • kilobyte 2.34%
  • megabyte 4.63%
  • gigabyte 6.87%
  • terabyte 9.05%
  • petabyte 11.18%
  • exabyte 13.26%

A practical example of this could be a storage device (e.g., HDDs, SSDs, USB drives), where a “1 TB” drive may appear as ~931 GB in the OS. However, RAM (memory) always uses binary prefixes (e.g., 8 GB RAM = 8 GiB).

ValueMetric
1000kB kilobyte
10002MB megabyte
10003GB gigabyte
10004TB terabyte
10005PB petabyte
10006EB exabyte
10007ZB zettabyte
10008YB yottabyte
10009RB ronnabyte
100010QB quettabyte
Decimal
ValueIEC
1024KiB kibibyte
10242MiB mebibyte
10243GiB gibibyte
10244TiB tebibyte
10245PiB pebibyte
10246EiB exbibyte
10247ZiB zebibyte
10248YiB yobibyte
10249RiB robibyte
102410QiB quebibyte
Binary