Convert binary numbers (base‑2) — both integer and fractional — to hexadecimal (base‑16). See 4‑bit grouping, detailed step‑by‑step breakdown, and decimal approximation.
Binary is the native language of computers, but real‑world numbers often include fractional parts (e.g., 10.101₂ = 2.625 decimal). Hexadecimal provides a compact, human‑readable representation where every 4 bits (a nibble) maps to a single hex digit — this rule applies to both integer and fractional parts. Converting fractional binary to hex is essential for digital signal processing, fixed‑point arithmetic, and understanding how computers store floating‑point numbers.
Conversion principle for fractional binary:
Binary: 1011 . 0110 → Hex: B . 6 → 0xB.6
Integer part grouped from right; fractional part grouped from left, trailing zeros added as needed.
Our converter follows a robust algorithm that handles both whole numbers and fractions:
This method guarantees exact conversion for binary numbers with finite binary expansion. For repeating binary fractions, the result is truncated to the given precision.
| Binary | Integer group (left‑padded) | Fraction group (right‑padded) | Hexadecimal | Decimal approx |
|---|---|---|---|---|
| 110110.011 | 11 0110 → 36 | 011 → 6 | 0x36.6 | 54.375 |
| 0.101 | 0 → 0 | 1010 → A | 0x0.A | 0.625 |
| 1011.1010 | 1011 → B | 1010 → A | 0xB.A | 11.625 |
| 1111.0001 | 1111 → F | 0001 → 1 | 0xF.1 | 15.0625 |
| 1.011 | 0001 → 1 | 0110 → 6 | 0x1.6 | 1.375 |
An embedded engineer needs to store the value 3.8125 in a 16‑bit fixed‑point register (8 integer bits, 8 fractional bits). Binary representation: 11.1101₂. Converting to hex: integer part "11" padded to "0011" → 3, fractional part "1101" → D. The final constant becomes 0x3.D. Writing 0x3D in a C header file is compact and error‑free compared to binary literal. Our converter automates this translation and shows grouping steps, ensuring correctness.