Base conversion basics


Table of Contents
Background
Base conversion is a fundamental concept in Information and Communication Technology (ICT) as it allows data to be represented, processed, and communicated across different systems. At its core, base conversion involves changing numbers from one numeral system to another, such as converting between binary (base-2), decimal (base-10), and hexadecimal (base-16). For example, the decimal number 10 is represented as 1010 in binary and A in hexadecimal.
Binary is the foundation of all computing, while decimal is the standard system for human use. Hexadecimal, often used by programmers, simplifies working with binary values because it represents each byte (8 bits) with two characters, making it more readable than long strings of 1s and 0s.
Base conversion is particularly critical in programming, where developers frequently work with different representations of data. For instance, converting a decimal number to hexadecimal can make debugging or configuring systems easier. While base conversion is most commonly associated with software development, it also plays a role in broader ICT applications, such as database management and hardware configuration (e.g., IP addresses).
In summary, understanding base conversion is essential for anyone working with computers, as it bridges the gap between human-readable numbers and machine-executable code. This skill not only enhances problem-solving abilities but also provides foundational knowledge for navigating digital systems in both software and hardware contexts.
Manual base conversions
Manual base conversion involves changing the representation of numbers from one base to another using arithmetic operations. For example, converting a number from decimal (base-10) to binary (base-2) requires repeatedly dividing the number by 2 and noting the remainder. These remainders form the binary digits when read in reverse order.
Similarly, converting a base-10 number to hexadecimal (base-16) involves dividing the number by 16, with each remainder representing a digit from 0-9 or A-F. The process is iterative: divide the quotient until you reach zero, and then read the remainders in reverse to obtain the new base representation. These conversions are fundamental in computer science, as they allow for easy manipulation of data at different levels of abstraction, such as binary for machine-level operations and hexadecimal for human readability.
Decimal to Hexadecimal Conversion Table
Decimal | Hexadecimal |
---|---|
0 | 0 |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
10 | A |
11 | B |
12 | C |
13 | D |
14 | E |
15 | F |
Examples
Decimal to binary conversion example
To convert the decimal number 29 to binary, follow these steps:
- Divide the number by 2. -> 29 / 2 = 14.5
- To get remainder take fractional part (.5) and multiply it by 2. -> 0.5 × 2 = 1
- Record the remainder (1) (either 0 or 1).
- Use the quotient (14) for the next division.
- Repeat until the quotient is 0.
Here’s a step-by-step breakdown:
Step | Division | Quotient | Remainder |
---|---|---|---|
1 | 29 ÷ 2 | 14 | 1 |
2 | 14 ÷ 2 | 7 | 0 |
3 | 7 ÷ 2 | 3 | 1 |
4 | 3 ÷ 2 | 1 | 1 |
5 | 1 ÷ 2 | 0 | 1 |
The binary representation is obtained by reading the remainders from bottom to top. Therefore, 29 in decimal converts to 11101 in binary.
Binary to decimal conversion example
To convert the binary number 11101 to decimal, follow these steps:
- Write down the binary number and assign each bit a power of 2, starting from the rightmost bit (which is \(2^0\)).
- Multiply each bit by its corresponding power of 2.
- Sum all the resulting values.
Here’s a step-by-step breakdown for 11101:
Bit Position | Binary Digit | Power of 2 | Calculation |
---|---|---|---|
4 | 1 | \(2^4\) | 16 |
3 | 1 | \(2^3\) | 8 |
2 | 1 | \(2^2\) | 4 |
1 | 0 | \(2^1\) | 0 |
0 | 1 | \(2^0\) | 1 |
Sum the results: \(16 + 8 + 4 + 0 + 1 = 29\)
Therefore, 11101 in binary converts to 29 in decimal.
Decimal to hexadecimal conversion example
To convert the decimal number 60028 to hexadecimal, follow these steps:
- Divide the number by 16 -> 60028 / 16 = 3751.75
- Take fractional part (.75) and multiply it by 16. -> 0.75 × 16 = 12
Another (longer) way for getting remainder is to (a) multiply quotient by 16 and (b) subtract value from original decimal number: (a) 3751 x 16 = 60016 -> (b) 60028 - 60016 = 12 - Record the remainder (12), which will be a digit (C) as shown in the “Decimal to Hexadecimal Conversion Table”
- Use the quotient (234) for the next division.
- Repeat until the quotient is 0.
Here’s a step-by-step breakdown:
Step | Division | Quotient | Remainder |
---|---|---|---|
1 | 60028 ÷ 16 | 3751 | 12 (C) |
2 | 3751 ÷ 16 | 234 | 7 |
3 | 234 ÷ 16 | 14 | 10 (A) |
4 | 14 ÷ 16 | 0 | 14 (E) |
The hexadecimal representation is obtained by reading the remainders from bottom to top. Therefore, 60028 in decimal converts to EA7C in hexadecimal.
Hexadecimal to decimal conversion example
To convert the hexadecimal number EA7C to decimal, follow these steps:
- Write down the hexadecimal number and assign each digit a power of 16, starting from the rightmost digit (which is \(16^0\)).
- Multiply each digit by its corresponding power of 16.
- Sum all the resulting values.
Here’s a step-by-step breakdown for EA7C:
Bit Position | Hex Digit | Decimal Value | Power of 16 | Calculation |
---|---|---|---|---|
3 | E | 14 | \(16^3\) | 57344 |
2 | A | 10 | \(16^2\) | 2560 |
1 | 7 | 7 | \(16^1\) | 112 |
0 | C | 12 | \(16^0\) | 12 |
Sum the results: \(57344 + 2560 + 112 + 12 = 60028\)
Therefore, EA7C in hexadecimal converts to 60028 in decimal.