Understand binary, octal, decimal and hexadecimal number systems,
then convert values between them using reliable step-by-step methods.
๐ฏ Learning Objectives
After completing this topic, you should be able to:
Identify the base and valid digits of a positional number system.
Convert decimal integers and fractions to another base.
Convert binary, octal and hexadecimal values to decimal.
Use bit grouping for fast binaryโoctal and binaryโhexadecimal conversions.
Verify conversions and avoid common digit and grouping mistakes.
Connect number bases with data representation in programs and computers.
๐ 1. Positional Number Systems
A positional number system gives each digit a value based on both the
digit itself and its position. The base tells us how many distinct digits
are available and what power is assigned to each position.
Important: The rightmost integer digit always has position 0.
Positions increase towards the left and become negative after the radix point.
๐งฉ 2. Common Bases Used in Programming
System
Base
Valid Digits
Example
Programming Use
Binary
2
0, 1
(101101)2
Bits, logic and machine data
Octal
8
0โ7
(735)8
Compact groups of three bits
Decimal
10
0โ9
(245)10
Everyday calculations
Hexadecimal
16
0โ9, AโF
(9AF)16
Memory, colours and bit patterns
Hexadecimal digit values
A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
โ 3. Decimal Integer to Another Base
Repeatedly divide the decimal number by the required base. Record each
remainder and read the remainders from bottom to top.
Divide the number by the target base.
Write the remainder.
Use the quotient as the next number.
Repeat until the quotient becomes 0.
Read the remainders in reverse order.
Convert (45)10 to binary
Target base = 2
Repeated division
45 รท 2 = 22, remainder 1
22 รท 2 = 11, remainder 0
11 รท 2 = 5, remainder 1
5 รท 2 = 2, remainder 1
2 รท 2 = 1, remainder 0
1 รท 2 = 0, remainder 1
Reading upwards: (45)10 = (101101)2
๐งฎ 4. Another Base to Decimal
Multiply every digit by the corresponding power of the source base,
beginning with power 0 at the rightmost digit, and add the results.
Convert (101101)2 to decimal
Expand using powers of 2.
Positional expansion
1ร25 + 0ร24 + 1ร23
+ 1ร22 + 0ร21 + 1ร20
32 + 0 + 8 + 4 + 0 + 1 = 45
(101101)2 = (45)10
3๏ธโฃ 5. Binary and Octal Conversion
One octal digit represents exactly three binary bits because 8 = 23.
Group binary digits in sets of three from the radix point outwards.
Binary โ Octal
(110 101 011)2
110 = 6, 101 = 5, 011 = 3
(653)8Octal โ Binary
(572)8
5 = 101, 7 = 111, 2 = 010
(101111010)2
Add leading or trailing zeroes only when necessary to complete a group of three.
These zeroes do not change the value.
4๏ธโฃ 6. Binary and Hexadecimal Conversion
One hexadecimal digit represents four binary bits because 16 = 24.
Group binary digits in sets of four.
Binary โ Hexadecimal
(1011 1100 0110)2
1011 = B, 1100 = C, 0110 = 6
(BC6)16Hexadecimal โ Binary
(3AF)16
3 = 0011, A = 1010, F = 1111
(001110101111)2
๐ 7. Octal and Hexadecimal Conversion
There is no direct digit grouping between octal and hexadecimal.
Use binary as the bridge.
Octal โ 3-bit binary groups โ regroup into 4 bits โ Hexadecimal
Convert (725)8 to hexadecimal
Step 1: Octal to binary
7 = 111, 2 = 010, 5 = 101
(725)8 = (111010101)2
Step 2: Regroup into four bits
0001 1101 0101 = 1 D 5
(725)8 = (1D5)16
๐น 8. Converting Fractional Parts
For a decimal fraction, repeatedly multiply the fractional part by the
target base. Record the integer part produced at each step and read the
recorded digits from top to bottom.
Convert (0.625)10 to binary
Repeated multiplication
0.625 ร 2 = 1.250 โ digit 1
0.250 ร 2 = 0.500 โ digit 0
0.500 ร 2 = 1.000 โ digit 1
(0.625)10 = (0.101)2
Some fractions repeat forever in another base. In such cases, stop at the
required precision and mark the result as approximate.
INTERACTIVE CONVERTER
๐งช 9. Base Conversion Explorer
Enter a valid integer or fractional value, choose the source and target
bases, and view both the result and the conversion method.
Select an example or enter a number, then click Convert Number.
๐งฎ 10. Solved Problems
Problem 1
Convert (156)10 to hexadecimal.
Solution
156 รท 16 = 9, remainder 12 = C
9 รท 16 = 0, remainder 9
(156)10 = (9C)16
Problem 2
Convert (347)8 to decimal.
Solution
3ร82 + 4ร81 + 7ร80
192 + 32 + 7 = 231
(347)8 = (231)10
Problem 3
Convert (2D7)16 to decimal.
Solution
2ร162 + 13ร161 + 7ร160
512 + 208 + 7 = 727
(2D7)16 = (727)10
โ ๏ธ 11. Common Mistakes and Quick Checks
Using an invalid digit
Binary cannot contain 2; octal cannot contain 8 or 9.
Reading remainders downwards
For repeated division, read remainders from bottom to top.
Grouping from the wrong side
Group integer bits from right to left and fractional bits from left to right.
Forgetting hexadecimal values
Remember that AโF represent decimal values 10โ15.
Verification method: Convert your final answer back to decimal.
Both representations must produce the same decimal value.
โ๏ธ 12. Practice Problems
Solve each conversion yourself before opening the solution.
You have learned, solved and revised the topic. Answer all 20
questions from easy to hard and submit once. Your score, correct
answers and explanations appear after submission.