Binary to Hex Converter and Multi-Base Calculator
This Binary To Hex Converter is a simple and user-friendly tool for converting numbers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) systems. It is designed for students, engineers, programmers, and anyone who needs to work with different number bases.
How to Use
- Enter a number in any of the input fields: Binary, Octal, Decimal, or Hexadecimal.
- The corresponding values in the other bases will be updated automatically.
- Only one field should be filled at a time. Invalid input will be highlighted in red.
- Supports both uppercase and lowercase letters for hexadecimal input.
Calculator
Conversion Algorithms & Demos
1. Binary ↔ Decimal
Binary to Decimal: Multiply each bit by 2n (n is the position from right, starting at 0), then sum up.
Demo: 10112 = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 1110
Decimal to Binary: Divide the decimal number by 2, record the remainder, repeat with the quotient until 0, then reverse the remainders.
Demo: 1310 → 11012
2. Octal ↔ Decimal
Octal to Decimal: Multiply each digit by 8n (n is the position from right, starting at 0), then sum up.
Demo: 258 = 2×8¹ + 5×8⁰ = 16 + 5 = 2110
Decimal to Octal: Divide the decimal number by 8, record the remainder, repeat with the quotient until 0, then reverse the remainders.
Demo: 4510 → 558
3. Hexadecimal ↔ Decimal
Hex to Decimal: Multiply each digit by 16n (n is the position from right, starting at 0), then sum up.
Demo: 1A16 = 1×16¹ + 10×16⁰ = 16 + 10 = 2610
Decimal to Hex: Divide the decimal number by 16, record the remainder, repeat with the quotient until 0, then reverse the remainders.
Demo: 3110 → 1F16
4. Binary ↔ Octal/Hexadecimal
Group binary digits by 3 (for octal) or 4 (for hex) from right, then convert each group.
Demo: 1101102 = 668 = 3616
Sample Code (JavaScript):
// Convert binary to decimal
parseInt('1011', 2); // 11
// Convert decimal to hex
(255).toString(16); // 'ff'
// Convert octal to decimal
parseInt('77', 8); // 63
// Convert decimal to binary
(42).toString(2); // '101010'
Base Table (1-255)
Decimal | Binary | Octal | Hexadecimal |
---|