Base Converter
Convert numbers between binary, octal, decimal and hexadecimal bases.
Back to all tools on ToolForge
Input
Result
Binary:
Octal:
Decimal:
Hex:
About Base Converter
This base converter switches numbers between binary, octal, decimal and hexadecimal formats instantly. It validates input against the selected base and displays results in all four common number systems used in computing.
Number Base Systems Compared
| Base | Digits | Bits per Digit | Common Use |
|---|---|---|---|
| Binary (2) | 0, 1 | 1 | Digital logic, bit operations |
| Octal (8) | 0-7 | 3 | Unix file permissions |
| Decimal (10) | 0-9 | - | Everyday counting |
| Hex (16) | 0-9, A-F | 4 | Memory addresses, colors |
Base Conversion Examples
Decimal 255 in all bases: Binary: 11111111 Octal: 377 Decimal: 255 Hex: FF Decimal 42 in all bases: Binary: 101010 Octal: 52 Decimal: 42 Hex: 2A Hex 0x100 in all bases: Binary: 100000000 Octal: 400 Decimal: 256 Hex: 100
How to Convert Decimal to Binary
Method 1: Repeated division by 2, track remainders:
Convert 13 to binary: 13 ÷ 2 = 6 remainder 1 6 ÷ 2 = 3 remainder 0 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 Read remainders bottom-to-top: 1101 Result: 13 (decimal) = 1101 (binary)
Method 2: Subtract powers of 2:
Convert 13 to binary: Powers of 2: 16, 8, 4, 2, 1 13 >= 8? Yes → 1, remainder 5 5 >= 4? Yes → 1, remainder 1 1 >= 2? No → 0 1 >= 1? Yes → 1 Result: 1101 (reading left to right: 8,4,2,1 positions)
Binary to Hexadecimal Conversion
Each hex digit represents exactly 4 binary bits:
Binary to Hex (group by 4 bits):
11010111 → group: 1101 0117
1101 = D (13 in decimal)
0111 = 7
Result: 0xD7
10101100110 → pad: 0101 0110 0110
5 6 6
Result: 0x566
Hex to Binary (expand each digit):
0x3F → 3 = 0011, F = 1111
Result: 00111111 = 111111
Common Hex Values Reference
| Hex | Decimal | Binary | Use Case |
|---|---|---|---|
| 0x00 | 0 | 00000000 | Null, false, off |
| 0x01 | 1 | 00000001 | Low bit set, true |
| 0x0F | 15 | 00001111 | Lower nibble mask |
| 0x10 | 16 | 00010000 | Bit 4 set |
| 0x7F | 127 | 01111111 | Max 7-bit value |
| 0x80 | 128 | 10000000 | High bit set |
| 0xFF | 255 | 11111111 | Max 8-bit value |
Common Use Cases
- Programming: Convert between binary literals, hex constants, and decimal values
- Embedded Systems: Work with register values, bit masks, and memory maps
- Network Engineering: Calculate subnet masks, IP addresses in hex
- Web Development: Convert color codes between hex and decimal RGB
- Computer Science: Learn number systems and practice conversions
- Reverse Engineering: Analyze binary data and memory dumps
Powers of 2 Reference
2^0 = 1 2^8 = 256 2^16 = 65,536 2^1 = 2 2^9 = 512 2^17 = 131,072 2^2 = 4 2^10 = 1,024 (1K) 2^20 = 1,048,576 (1M) 2^3 = 8 2^11 = 2,048 2^24 = 16,777,216 (16M) 2^4 = 16 2^12 = 4,096 2^30 = 1,073,741,824 (1G) 2^5 = 32 2^13 = 8,192 2^6 = 64 2^14 = 16,384 2^7 = 128 2^15 = 32,768
How to Convert Between Number Bases
- Enter value: Type the number you want to convert.
- Select base: Choose the base of your input (binary, octal, decimal, or hex).
- Click Convert: The tool displays the value in all four bases.
- Copy result: Use the converted values in your code or documentation.
Tips
- Input is validated against the selected base automatically
- Hex letters can be uppercase or lowercase
- Negative numbers are supported in decimal
- Results are displayed in all bases simultaneously
Frequently Asked Questions
- What are number bases and how do they work?
- A number base (radix) defines how many unique digits represent numbers. Binary (base-2) uses 0-1, octal (base-8) uses 0-7, decimal (base-10) uses 0-9, and hexadecimal (base-16) uses 0-9 and A-F. Each position represents a power of the base.
- Why is hexadecimal used in computing?
- Hexadecimal is compact and human-readable. One hex digit represents exactly 4 binary bits, making conversion trivial. A byte (8 bits) is exactly 2 hex digits (00-FF). Memory addresses, colors, and binary data are commonly shown in hex.
- How do you convert decimal to binary?
- Divide the decimal number by 2 repeatedly, tracking remainders. Read remainders bottom-to-top. Example: 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1. Result: 1101. Or use powers of 2: 13 = 8+4+1 = 1101.
- How do you convert binary to hexadecimal?
- Group binary digits into sets of 4 (starting from right), then convert each group to hex. Example: 11010111 → 1101 0117 → D 7 → 0xD7. Each 4-bit pattern maps directly to one hex digit (0000=0 to 1111=F).
- What is octal used for?
- Octal was common in older systems with word lengths divisible by 3. Today it's used for Unix file permissions (rwx = 0-7, shown as 755 or 644). Each octal digit represents exactly 3 binary bits, like hex represents 4 bits.
- What are common binary/hex patterns to memorize?
- Key patterns: 0x0F = 00001111 (lower nibble), 0xFF = 11111111 (byte), 0x10 = 16 decimal. Powers of 2: 2^8=256=0x100, 2^16=65536=0x10000. Bit masks: 0x80 = 10000000 (high bit), 0x01 = 00000001 (low bit).