Number Systems in Maths: Decimal, Binary, Octal, and Hexadecimal
Understand positional number systems and learn to convert whole numbers and fractions between binary, octal, decimal, and hexadecimal.
TL;DR
A positional number system writes values using digits and a base. Decimal uses base 10, binary uses base 2, octal uses base 8, and hexadecimal uses base 16. Place values are powers of the base.
Key Points
- The base tells you how many digit values are available and how adjacent places relate.
- Digits in base have values from zero through .
- Read a numeral by multiplying each digit by its place value and adding the results.
- To convert a decimal whole number to another base, divide repeatedly and read the remainders from last to first.
- A base changes how a number looks. Sets such as integers and rational numbers classify its value.
What is a number system in maths?
A number system is a way to represent numbers. In a positional number system, both the digit and its position contribute to the value. For instance, the same 2 represents twenty in and sixteen in . In the first numeral it occupies the tens place. In the second it occupies the eights place.
The small subscript names the base. Use it when more than one base appears. For example, , , , and have values two, eight, ten, and sixteen respectively. The units place always has weight in base . Moving one place to the left multiplies the weight by . OpenStax, Introduction to Whole Numbers
Roman numerals also represent numbers, with rules for combining symbols. Their letters do not mark columns of base powers. See the Roman numerals chart for a comparison.
What are the four common positional number systems?
| System | Base | Digits | Where you may see it |
|---|---|---|---|
| Binary | 2 | 0 and 1 | Digital circuits and bit patterns |
| Octal | 8 | 0 through 7 | Compact notation for groups of three bits |
| Decimal | 10 | 0 through 9 | Everyday measurements and calculations |
| Hexadecimal | 16 | 0 through 9, then A through F | Compact notation for groups of four bits |
Hexadecimal uses A for ten, B for eleven, C for twelve, D for thirteen, E for fourteen, and F for fifteen. So means one sixteen plus fifteen ones. Octal has no digit 8, just as binary has no digit 2. McMaster University, Number Systems
How do you read any base in decimal?
Starting from the units place, label the positions as you move left. Multiply each digit by its position’s value. For a numeral with three digits , the number is
To the right of the radix point, use . For instance, the first place after the point in binary is worth one-half, and the first place after the point in octal is worth one-eighth. This extends the familiar place-value rule for tenths and hundredths.
How do you convert decimal to binary, octal, or hexadecimal?
For a whole number, divide by the target base and save the remainder. Divide the quotient again until it is zero. Each division peels off the next digit from the right. Read the remainders from the bottom up. Convert remainders 10 through 15 to A through F for hexadecimal.
For a fractional part, multiply it by the target base. Take the integer part as the next digit to the right of the point and repeat with the new fractional part. Read those digits in the order you find them. A fraction can terminate in one base and repeat in another. A reduced fraction with denominator terminates in base exactly when divides some power of . Decimal has denominator 10, so it repeats in binary because no power of 2 has a factor of 5. Open Book Project, Number Systems and Complements
When can you convert without going through decimal?
Since , every octal digit corresponds to three binary digits. Since , every hexadecimal digit corresponds to four. Separate the binary digits into groups from the radix point outward. On the whole-number side you may pad the far left with zeros. On the fractional side you may pad the far right. Padding on the wrong end shifts the values.
To convert between octal and hexadecimal, expand each digit into binary, then regroup around the same point. The binary number system guide and hexadecimal conversion guide apply the method to longer numerals.
How are numeral systems different from number sets?
A base tells you how to write a value. A number set tells you which values a category contains. The same number 12 is represented by , , and . In all three forms it is a positive integer and a rational number.
In much school mathematics, natural numbers start at 1, while whole numbers start at 0. Some textbooks include 0 in the natural numbers. Integers include the negative whole numbers, zero, and the positive whole numbers. A rational number can be written as a ratio of integers with a nonzero denominator. Irrational numbers such as are real numbers outside that set. OpenStax, Real Numbers: Algebra Essentials
Worked Number-System Examples
Example 1
Convert to decimal.
- Label the five places 16, 8, 4, 2, and 1.
- The ones occur in the 16, 4, and 2 places.
- Add .
Example 2
Convert to decimal.
- The positions have values 64, 8, and 1.
- Multiply the digits by their weights: , , and .
- Add .
Example 3
Write decimal 94 in hexadecimal.
- Divide 94 by 16 to get quotient 5 and remainder 14.
- Divide 5 by 16 to get quotient 0 and remainder 5.
- Read the remainders up. Since 14 is E, the result is . Check .
Example 4
Convert to octal and hexadecimal.
- Group the integer places from the right in threes: , , .
- These groups give .
- Group instead in fours: , . These give . Both represent decimal 107.
Example 5
Write decimal in binary.
- Double to get . Take digit 1 and keep .
- Double to get . Take digit 0. Doubling gives , so take digit 1.
- Doubling the final gives , so take digit 1 and stop. The result equals .
Example 6
Add directly in octal.
- The units digits sum to in decimal. That is one group of eight plus five, so write 5 and carry 1.
- The eights digits sum to .
- The result is . A decimal check gives .
Mistakes That Change Base Conversion
Mistake 1: Using a digit too large for the base
is invalid because 8 is not an octal digit. A single position can hold only zero through seven. Eight units carry into the next position.
Mistake 2: Reading the division remainders from top to bottom
The first remainder belongs in the units place. For decimal 19, dividing repeatedly by 2 produces remainders 1, 1, 0, 0, 1 in that order. Reading upward gives .
Mistake 3: Dropping a zero within a numeral
A zero can hold an empty place. In , it keeps the 2 in the sixty-fours place. Removing it gives , which has a different value.
Try It Yourself
- Convert to decimal.
- Write decimal 45 in binary.
- Convert to decimal.
Answers and Reasoning
- The value is .
- . Its ones are in the 32, 8, 4, and 1 positions.
- The value is .
Frequently Asked Questions
Why do number systems use different bases?
Base 10 is the convention for most daily arithmetic. Base 2 uses two states, making it practical for digital representation. Octal and hexadecimal save space when people read and write binary values.
Is the same number as ?
No. In binary, . The decimal numeral means eleven hundredths.
Does a negative number require a new digit?
Ordinary mathematical notation can use a minus sign before the numeral. A digital format may use a separate convention such as two’s complement. Its interpretation depends on bit width.
Conclusion
- Identify the base and check that every digit is allowed.
- Use powers of the base to read a numeral or repeated division to write a whole number in a new base.
- Verify a conversion by evaluating the result in decimal.
Read More
Research Behind This Article
- OpenStax, Prealgebra 2e: Introduction to Whole Numbers. OpenStax
- McMaster University, 4D6 Lab Manual: Number Systems. McMaster Physics
- The Open Book Project, Number Systems and Complements. Open Book Project
- OpenStax, College Algebra 2e: Real Numbers, Algebra Essentials. OpenStax