Engineering & Number Systems
Convert Decimal Bytes (0–255) To & From Hexadecimal and Octal (Positional Radix Math)
Convert 8-bit RGB channels, register bytes, and permissions between Decimal, 2-digit Hexadecimal, and 3-digit Octal using positional INT, MOD, MID, and FIND.
Translate 8-bit bytes across Base-10, Base-16 (Hex), and Base-8 (Octal)
Design systems express RGB color channels (0..255) as two-digit uppercase hexadecimal bytes ("00".."FF"), while Unix file modes and hardware registers often inspect three-digit octal ("000".."377"). Any byte N in 0..255 decomposes in base 16 as 16 * INT(N / 16) + MOD(N, 16) and in base 8 as 64 * INT(N / 64) + 8 * MOD(INT(N / 8), 8) + MOD(N, 8).
Indexing into the 16-character alphabet "0123456789ABCDEF" via MID(..., digit + 1, 1) formats exact zero-padded hex bytes, while FIND(char, "0123456789ABCDEF") - 1 parses hex strings back to decimal.
| Decimal Byte | Base-16 Nibbles | 2-Digit Hex | 3-Digit Octal |
|---|---|---|---|
| 0 | 0 * 16 + 0 | 00 | 000 |
| 42 | 2 * 16 + 10 | 2A | 052 |
| 175 | 10 * 16 + 15 | AF | 257 |
| 255 | 15 * 16 + 15 | FF | 377 |
Decimal Byte (0..255) to Zero-Padded 2-Digit Hexadecimal
Validates integer byte B2 in 0..255 and maps high and low nibbles onto "0123456789ABCDEF".
=IF(OR(B2 < 0, B2 > 255, B2 <> INT(B2)), "Byte 0..255 Required", MID("0123456789ABCDEF", INT(B2 / 16) + 1, 1) & MID("0123456789ABCDEF", MOD(B2, 16) + 1, 1))2-Character Hexadecimal Byte Back to Decimal (0..255)
Parses uppercase or lowercase 2-character hex string B3 into its decimal value.
=IF(LEN(B3) <> 2, "2-Char Hex Required", (FIND(MID(UPPER(B3), 1, 1), "0123456789ABCDEF") - 1) * 16 + (FIND(MID(UPPER(B3), 2, 1), "0123456789ABCDEF") - 1))Try the example
Use the original values or change them to test your understanding.