Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Number bases are systems for writing numbers using different sets of digits. This cheat sheet covers decimal, binary, octal, and hexadecimal notation used in computer science. Students need these bases because computers store and process data using bits, and programmers often use octal or hexadecimal as shorter ways to write binary values.

The core idea is place value: each digit is multiplied by a power of the base. Binary uses base 2, octal uses base 8, decimal uses base 10, and hexadecimal uses base 16. Conversions often use repeated division, place value expansion, or grouping binary digits into sets of 3 for octal and sets of 4 for hexadecimal.

Key Facts

  • In base b, each digit place represents a power of b, such as b^0, b^1, b^2, and b^3 from right to left.
  • Binary is base 2 and uses only the digits 0 and 1.
  • Octal is base 8 and uses the digits 0 through 7.
  • Hexadecimal is base 16 and uses the digits 0 through 9 and the letters A, B, C, D, E, and F for values 10 through 15.
  • To convert a number to decimal, multiply each digit by its place value and add the results, such as 1011_2 = 1×8 + 0×4 + 1×2 + 1×1 = 11.
  • To convert decimal to another base, repeatedly divide by the new base and read the remainders from bottom to top.
  • To convert binary to octal, group bits in sets of 3 from the right, because 8 = 2^3.
  • To convert binary to hexadecimal, group bits in sets of 4 from the right, because 16 = 2^4.

Vocabulary

Base
The number of different digit symbols used in a number system.
Binary
A base 2 number system that uses only 0 and 1.
Octal
A base 8 number system that uses the digits 0 through 7.
Hexadecimal
A base 16 number system that uses digits 0 through 9 and letters A through F.
Bit
A single binary digit, either 0 or 1.
Place Value
The value of a digit based on its position in a number and the base being used.

Common Mistakes to Avoid

  • Using invalid digits for a base is wrong because each base has a limited digit set, such as no 2 in binary and no 8 or 9 in octal.
  • Reading binary like decimal is wrong because 1010_2 means 1×8 + 0×4 + 1×2 + 0×1, not one thousand ten.
  • Grouping binary digits from the left first is wrong for octal and hexadecimal because groups must start from the right, with zeros added on the left if needed.
  • Forgetting that A through F are numbers in hexadecimal is wrong because A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.
  • Reading remainders from top to bottom after repeated division is wrong because the correct converted number is formed by reading the remainders from bottom to top.

Practice Questions

  1. 1 Convert 110101_2 to decimal.
  2. 2 Convert 45_10 to binary using repeated division by 2.
  3. 3 Convert 3F_16 to decimal.
  4. 4 Explain why hexadecimal is often easier for humans to read than long binary strings.

Understanding Number Bases (Binary, Octal, Hex)

A base is really a rule about which symbols are allowed and when a new place is needed. In decimal, a new place appears after nine. In hexadecimal, it appears after F, whose value is fifteen.

This means that a digit can be valid in one base but invalid in another. The symbol 8 cannot appear in octal. A common mistake is treating hexadecimal letters as letters in a word.

They are digits with fixed values. Capital and lowercase forms usually mean the same thing in code.

Leading zeroes need care too. They do not change a number's value in most contexts, but some programming languages have used a leading zero to signal octal notation.

The fastest conversion methods work because some bases fit binary exactly. One octal digit represents the same range as three binary digits. One hexadecimal digit represents the same range as four binary digits.

Start grouping at the rightmost bit. If the leftmost group is too short, add zeroes only on its left. Adding zeroes elsewhere changes the value.

For example, a binary group such as 011 has the same value as 11, but inserting a zero inside a sequence changes which places contain ones. Students should write groups with spaces while practicing. This makes it easier to spot a missing bit or a group of the wrong size.

Computers use binary because electronic circuits can reliably distinguish two states, often represented as off and on. A single binary digit is called a bit. Eight bits make a byte.

Bytes are used to store text characters, small pieces of images, sound samples, and program data. The same pattern of bits can mean different things depending on how a program reads it. A byte might represent a letter, a small whole number, or part of a colour value.

Hexadecimal is useful here because two hex digits describe exactly one byte. It gives programmers a compact way to inspect memory values without losing the direct connection to the underlying bits.

Number bases matter beyond classroom conversion exercises. Web colours are often written with six hexadecimal digits. Each pair controls the amount of red, green, or blue light in a colour.

File permissions on some computer systems are commonly shown in octal. Debugging tools may show memory addresses and machine instructions in hexadecimal. When working with signed binary numbers, the leftmost bit may indicate whether a value is negative.

This is why a bit pattern cannot be interpreted correctly without knowing its size and format. Pay close attention to the stated base, the direction of place values, grouping boundaries, and whether a result needs leading zeroes to fill a fixed number of bits.