Memahami sistem bilangan (Desimal, Biner, Heksadesimal) + Konversinya
Table of Contents
Introduction
This tutorial aims to provide a comprehensive understanding of number systems, specifically decimal, binary, and hexadecimal, along with techniques for converting between these systems. This knowledge is essential for anyone studying computer science, as these number systems form the backbone of digital computing.
Step 1: Understanding Number Systems
Decimal System
- Base 10 system.
- Uses digits from 0 to 9.
- Commonly used in everyday mathematics.
Binary System
- Base 2 system.
- Uses digits 0 and 1.
- Fundamental in computer systems, representing on/off states.
Hexadecimal System
- Base 16 system.
- Uses digits from 0 to 9 and letters A to F (A=10, B=11, C=12, D=13, E=14, F=15).
- Often used in programming and to simplify binary representation.
Step 2: Converting Decimal to Binary
To convert a decimal number to binary:
- Divide the decimal number by 2.
- Record the remainder (0 or 1).
- Update the decimal number to the quotient.
- Repeat until the quotient is zero.
- The binary number is the remainders read in reverse order.
Example
Convert 13 to binary:
- 13 ÷ 2 = 6 remainder 1
- 6 ÷ 2 = 3 remainder 0
- 3 ÷ 2 = 1 remainder 1
- 1 ÷ 2 = 0 remainder 1
- Binary: 1101
Step 3: Converting Binary to Decimal
To convert a binary number to decimal:
- Write down the binary number.
- Assign powers of 2 from right to left, starting from 0.
- Multiply each binary digit by its corresponding power of 2.
- Sum all the results.
Example
Convert 1101 to decimal:
- (1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2^0) = 8 + 4 + 0 + 1 = 13
Step 4: Converting Decimal to Hexadecimal
To convert a decimal number to hexadecimal:
- Divide the decimal number by 16.
- Record the remainder.
- Update the decimal number to the quotient.
- Repeat until the quotient is zero.
- Convert remainders above 9 (10-15) to A-F, and read in reverse order.
Example
Convert 255 to hexadecimal:
- 255 ÷ 16 = 15 remainder 15 (F)
- 15 ÷ 16 = 0 remainder 15 (F)
- Hexadecimal: FF
Step 5: Converting Hexadecimal to Decimal
To convert a hexadecimal number to decimal:
- Write down the hexadecimal number.
- Assign powers of 16 from right to left, starting from 0.
- Multiply each hex digit by its corresponding power of 16.
- Sum all the results.
Example
Convert FF to decimal:
- (15 * 16^1) + (15 * 16^0) = 240 + 15 = 255
Step 6: Converting Binary to Hexadecimal
To convert binary to hexadecimal:
- Group the binary digits into sets of four, starting from the right (add leading zeros if necessary).
- Convert each group to its hexadecimal equivalent.
Example
Convert 11010100 to hexadecimal:
- Group: 1101 0100
- Convert: D4 (D=13, 4=4)
Step 7: Converting Hexadecimal to Binary
To convert hexadecimal to binary:
- Replace each hex digit with its 4-bit binary equivalent.
Example
Convert A3 to binary:
- A = 1010, 3 = 0011
- Result: 10100011
Conclusion
Understanding and converting between decimal, binary, and hexadecimal systems is crucial in computer science. With practice, these conversion techniques will become second nature. Consider applying these concepts in programming tasks or digital electronics to deepen your understanding.