
Test Article
Table of Contents
Number System Converter
Invalid input for the selected number system."; } else { $decimalValue = base_convert($inputNumber, $inputBase, 10); $binaryValue = base_convert($decimalValue, 10, 2); $octalValue = base_convert($decimalValue, 10, 8); $hexValue = strtoupper(base_convert($decimalValue, 10, 16)); echo "Conversion Results:
"; echo "Decimal: $decimalValue
"; echo "Binary: $binaryValue
"; echo "Octal: $octalValue
"; echo "Hexadecimal: $hexValue
"; echo "Understanding Number Systems & Conversions
1. Decimal to Binary Conversion
To convert a decimal number to binary, divide it by 2 repeatedly and note the remainders.
Example: Convert 13
(Decimal) to Binary.
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Answer: 1101
(Binary)
2. Binary to Decimal Conversion
Multiply each binary digit by 2 raised to its position power.
Example: Convert 1011
(Binary) to Decimal.
(1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰)
= (8) + (0) + (2) + (1)
= 11
(Decimal)
3. Decimal to Octal Conversion
Divide the decimal number by 8 repeatedly and note the remainders.
Example: Convert 45
(Decimal) to Octal.
45 ÷ 8 = 5 remainder 5
5 ÷ 8 = 0 remainder 5
Answer: 55
(Octal)
4. Octal to Decimal Conversion
Multiply each octal digit by 8 raised to its position power.
Example: Convert 57
(Octal) to Decimal.
(5 × 8¹) + (7 × 8⁰)
= (40) + (7)
= 47
(Decimal)
5. Decimal to Hexadecimal Conversion
Divide the decimal number by 16 repeatedly and note the remainders.
Example: Convert 255
(Decimal) to Hexadecimal.
255 ÷ 16 = 15 remainder 15 (15 = F in Hex)
15 ÷ 16 = 0 remainder 15 (15 = F in Hex)
Answer: FF
(Hexadecimal)
6. Hexadecimal to Decimal Conversion
Multiply each hexadecimal digit by 16 raised to its position power.
Example: Convert 1A3
(Hex) to Decimal.
(1 × 16²) + (A × 16¹) + (3 × 16⁰)
= (1 × 256) + (10 × 16) + (3 × 1)
= (256) + (160) + (3)
= 419
(Decimal)