Number Conversion Tutorial
This guide is designed to help you easily convert between various numbering systems used in computing and mathematics. Whether you're working with binary, decimal, hexadecimal, or octal, this tutorial provides the formulas and examples you need to make accurate conversions.
In the sections below, you will find detailed explanations and step-by-step examples for converting between different numbering systems.
Number Systems
There are several commonly used number systems:
- Binary: Base-2 numerical system, composed of only 0s and 1s.
- Decimal: Base-10 numerical system, composed of digits from 0 to 9.
- Octal: Base-8 numerical system, composed of digits from 0 to 7.
- Hexadecimal: Base-16 numerical system, composed of digits from 0 to 9 and letters from A to F.
- Text: Represents characters using their ASCII values or Unicode code points.
Conversion Methods
To convert a number from one system to another, different methods are used:
- Direct Conversion: Directly convert the number to its equivalent in the target system.
- Decimal Intermediary: Convert the number to its decimal equivalent first, then convert to the target system.
- Text-to-Binary Conversion: Convert text characters to their binary representation using ASCII or Unicode.
- Binary-to-Text Conversion: Convert binary numbers to text characters using ASCII or Unicode.
Conversion Logic
The following outlines the conversion logic for some common conversions:
- Binary to Decimal: Each digit is multiplied by 2 raised to the power of its position, starting from the rightmost digit.
- Decimal to Binary: Divide the decimal number by 2 successively, recording the remainders in reverse order to obtain the binary equivalent.
- Hexadecimal to Decimal: Each digit is multiplied by 16 raised to the power of its position, starting from the rightmost digit. Hexadecimal letters are converted to their decimal equivalents.
- Decimal to Hexadecimal: Divide the decimal number by 16 successively, recording the remainders in reverse order. Convert remainders greater than 9 to their corresponding hexadecimal letters.
Binary to Decimal (bin to dec)
Formula: Decimal = Sum of binary digits * (2^position)
Example: Convert 1010 (binary) to Decimal.
Solution: 1*2^3 + 0*2^2 + 1*2^1 + 0*2^0 = 8 + 0 + 2 + 0 = 10
Decimal to Hexadecimal (dec to hex)
Formula: Divide the decimal number by 16 and use the remainder.
Example: Convert 255 (decimal) to Hexadecimal.
Solution: 255 / 16 = 15 remainder 15, which is FF in hex.
Hexadecimal to Octal (hex to oct)
Formula: Convert hex to binary, then binary to octal.
Example: Convert 1F (hex) to Octal.
Solution: 1F in binary is 0001 1111, which in octal is 37.
Octal to Binary (oct to bin)
Formula: Convert each octal digit to a 3-bit binary equivalent.
Example: Convert 17 (octal) to Binary.
Solution: 1 is 001 and 7 is 111, so 17 in binary is 001 111.