Binary Converter Guide: Convert Binary, Decimal, Hex & Octal Numbers
A binary & hex converter switches between binary, decimal, hexadecimal, and octal using positional notation. It supports signed/unsigned values, fixed bit widths, and quick grouping rules (4-bit nibbles for hex, 3-bit groups for octal).
What is Binary & Hex Converter?
The binary & hex converter is a developer’s and student’s tool for number-base conversions, bitwise intuition, and debugging. It’s handy for microcontrollers, networking, and low-level programming.
How to Use the Binary & Hex Converter
- Choose the base you have (binary/decimal/hex/octal).
- Enter the value and select bit width (e.g., 8, 16, 32, 64) and signed/unsigned.
- Convert to see all bases; copy the format you need.
- Optional: toggle two’s complement interpretation for negatives.
- Use grouping (4 bits ↔ 1 hex digit; 3 bits ↔ 1 octal digit) for mental checks.
Formulas & Methods
- Positional value:
value = Σ digit_i × base^i
(least significant bit/digit at i=0). - Binary ↔ Hex: group 4 bits per hex digit (e.g.,
1011 1100
→0xBC
). - Binary ↔ Octal: group 3 bits per octal digit (e.g.,
111 010
→0o72
). - Two’s complement (n bits): Negative
x
=2^n − |x|
; convert by inverting bits and adding 1. - Masks & shifts: use
AND/OR/XOR
,<<
,>>
to manipulate fields.
Assumptions & limitations
- Leading zeros may be trimmed unless fixed width is requested.
- Endianness affects memory layout, not the mathematical value.
Examples
Example A — Binary → Decimal
11010110₂ = 1·2^7 + 1·2^6 + 0·2^5 + 1·2^4 + 0·2^3 + 1·2^2 + 1·2^1 + 0 = 214₁₀
.
Example B — Signed 8-bit two’s complement
1110 1110₂
→ as unsigned = 238
. As signed: 238 − 256 = −18
.
| Input | Output |
|---|---|
| 0b10111100
| 188
(dec), 0xBC
(hex), 0o274
(oct) |
| -42
(8-bit) | 1101 0110₂
|
Pro Tips & Best Practices
- Fix bit width before interpreting two’s complement.
- Use underscores or spaces in long binaries for readability.
- Confirm endianness when reading raw bytes from hardware or files.
- Learn common masks (e.g.,
0xFF
,0xF0
) for quick field extraction.
Related Calculators
FAQ
Q: How do I convert binary to decimal?
A: Sum bit values where a 1 appears: decimal = Σ bit×2^position.
Q: How do hex and binary relate?
A: 1 hex digit = 4 binary bits; group bits in fours to convert quickly.
Q: What about octal?
A: 1 octal digit = 3 bits; group bits in threes.
Q: How do I handle negatives?
A: Use two’s complement: invert bits and add 1 to represent negatives with a fixed bit width.
Q: What’s endianness?
A: Byte order in memory (little vs big). It affects storage, not the numeric value itself.
Engineering note: SI units and conventional digital bases (2, 8, 10, 16). Signed math uses two’s complement unless stated otherwise.
Call to Action
Paste a value in any base and see the others instantly—then explore bit masks and two’s complement with fixed widths to sharpen intuition.