Computer Number System

Understanding How Computers Represent and Process Numbers

What is a Number System?
Definition
A number system is a way to represent numbers using a set of symbols (digits).

In computers, everything (numbers, text, images, sound) is ultimately stored as binary numbers (0 and 1). But we often use other number systems (decimal, octal, hexadecimal) for convenience.
Types of Number Systems in Computers
Decimal
Base 10
Digits: 0–9
Each digit's position = power of 10.
This is the number system humans use every day.
Example
452 = (4 × 10²) + (5 × 10¹) + (2 × 10⁰)
= 400 + 50 + 2 = 452
Binary
Base 2
Digits: 0, 1 only
Each position = power of 2.
This is the language of computers (everything is stored in 0s and 1s).
Example
(1011)₂ = (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰)
= 8 + 0 + 2 + 1 = 11 in decimal
Octal
Base 8
Digits: 0–7
Each position = power of 8.
Used in older systems for compact binary representation.
Example
(157)₈ = (1 × 8²) + (5 × 8¹) + (7 × 8⁰)
= 64 + 40 + 7 = 111 in decimal
Hexadecimal
Base 16
Digits: 0–9, A–F (where A=10, B=11, … F=15)
Each position = power of 16.
Used in modern computing (short way to write binary numbers).
Example
(2F)₁₆ = (2 × 16¹) + (15 × 16⁰)
= 32 + 15 = 47 in decimal
Conversion Between Number Systems
Decimal → Binary
Method: Division by 2
1
Divide the decimal number by 2
2
Record the remainder (0 or 1)
3
Continue with the quotient until it becomes 0
4
Read remainders from bottom to top
Example: Convert 25₁₀ to binary
25 ÷ 2 = 12 remainder 1
12 ÷ 2 = 6 remainder 0
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Read bottom → top: 11001₂
So, 25₁₀ = 11001₂
Binary → Decimal
Method: Multiplication by powers of 2
1
Write down the binary number
2
Assign powers of 2 to each position (from right to left, starting with 2⁰)
3
Multiply each digit by its power of 2
4
Add all the results
Example: Convert 10110₂ to decimal
(1 × 2⁴) + (0 × 2³) + (1 × 2²) + (1 × 2¹) + (0 × 2⁰)
= (1 × 16) + (0 × 8) + (1 × 4) + (1 × 2) + (0 × 1)
= 16 + 0 + 4 + 2 + 0 = 22₁₀
Binary → Hexadecimal
Method: Grouping into 4 bits
1
Group the binary digits into sets of 4 (from right to left)
2
Add leading zeros if needed to complete a group of 4
3
Convert each 4-bit group to its hexadecimal equivalent
Example: Convert 11010110₂ to hex
Group into 4 bits: 1101 0110
1101₂ = 13₁₀ = D₁₆
0110₂ = 6₁₀ = 6₁₆
So, 11010110₂ = D6₁₆
Hexadecimal → Binary
Method: Convert each hex digit to 4-bit binary
1
Write down the hexadecimal number
2
Convert each hexadecimal digit to its 4-bit binary equivalent
3
Concatenate all the 4-bit groups
Example: Convert A3₁₆ to binary
A₁₆ = 10₁₀ = 1010₂
3₁₆ = 3₁₀ = 0011₂
So, A3₁₆ = 1010 0011₂
Fractions in Number Systems
Method: Multiplication by 2 (for decimal to binary)
0.625 × 2 = 1.25
Take 1 (integer part)
0.25 × 2 = 0.5
Take 0 (integer part)
0.5 × 2 = 1.0
Take 1 (integer part)
So, 0.625₁₀ = 0.101₂
Why Different Number Systems?
Binary
The actual machine language of computers. All data is ultimately stored and processed as binary (0s and 1s).
Octal/Hexadecimal
Short representation of binary numbers, used by programmers for convenience. One hex digit represents 4 binary digits.
Decimal
For human understanding and everyday use. Most familiar to people as it's used in daily life.
Example
Instead of writing 110101111001₂ (12 bits), we can write just DF9₁₆ (3 hex digits).
Summary
Computers internally work in binary, but humans use decimal/hex for convenience.
Decimal
Base 10 (0–9)
Binary
Base 2 (0–1)
Octal
Base 8 (0–7)
Hexadecimal
Base 16 (0–9, A–F)