How to Use Base Conversion Functions in Microsoft Excel for Binary, Octal, and Hexadecimal Numbers

Computer scientists, embedded firmware engineers, network architects, and cybersecurity analysts frequently work with numbers expressed across different mathematical radix bases. Whether parsing memory register offsets in hexadecimal (Base 16), calculating IP subnet bitmasks in binary (Base 2), or interpreting system permissions in octal (Base 8), manually converting these values into standard decimal (Base 10) numbers invites arithmetic errors. Microsoft Excel provides a complete, built-in suite of engineering functions designed specifically for automated base conversions.

In this tutorial, you will learn how to convert numbers between binary, octal, decimal, and hexadecimal formats in Microsoft Excel, enforce fixed bit-length padding, and avoid common overflow limits.

Understanding Number Bases in Excel

Modern computing uses four fundamental numeral systems:

  • Binary (Base 2): Uses only two symbols, 0 and 1.
  • Octal (Base 8): Uses digits 0 through 7. Common in Unix file permissions.
  • Decimal (Base 10): Standard human numbering system using digits 0 through 9.
  • Hexadecimal (Base 16): Uses digits 0 through 9 and letters A through F (representing values 10 through 15). Common in memory addresses, colour codes, and MAC addresses.

Excel provides twelve direct conversion functions following the naming pattern [SOURCE]2[TARGET]:

Function Source Base Target Base Example Syntax
BIN2DEC Binary (Base 2) Decimal (Base 10) =BIN2DEC(1101) → 13
DEC2BIN Decimal (Base 10) Binary (Base 2) =DEC2BIN(13) → "1101"
HEX2DEC Hexadecimal (Base 16) Decimal (Base 10) =HEX2DEC("1A") → 26
DEC2HEX Decimal (Base 10) Hexadecimal (Base 16) =DEC2HEX(26) → "1A"
BIN2HEX Binary (Base 2) Hexadecimal (Base 16) =BIN2HEX(11111111) → "FF"
HEX2BIN Hexadecimal (Base 16) Binary (Base 2) =HEX2BIN("F") → "1111"
OCT2DEC Octal (Base 8) Decimal (Base 10) =OCT2DEC(755) → 493
DEC2OCT Decimal (Base 10) Octal (Base 8) =DEC2OCT(493) → "755"

1. Converting to and from Binary: BIN2DEC and DEC2BIN

BIN2DEC Syntax

=BIN2DEC(number)

Accepts a binary number (up to 10 characters / bits). If the highest bit (10th bit) is 1, the number is interpreted as a negative value using two’s complement notation.

DEC2BIN Syntax with Places Argument

=DEC2BIN(number, [places])
  • number (Required): The integer you wish to convert. Can range from -512 to 511.
  • places (Optional): The number of characters to use in the output string. If the converted binary result has fewer digits than places, Excel pads leading zeros to match fixed register byte or nibble widths.

Example: Pad decimal 5 to an 8-bit byte representation:

=DEC2BIN(5, 8)

Output: "00000101".

2. Converting to and from Hexadecimal: HEX2DEC and DEC2HEX

HEX2DEC Syntax

=HEX2DEC(number)

Accepts a hexadecimal string up to 10 characters (40 bits). Hexadecimal values can be entered enclosed in quotes (e.g., "FF") or referenced directly from adjacent cells.

DEC2HEX Syntax with Places Argument

=DEC2HEX(number, [places])

Converts a decimal number (from -549,755,813,888 to 549,755,813,887) to hexadecimal, supporting leading zero padding via places.

Example: Formatting a 32-bit register address:

=DEC2HEX(255, 4)

Output: "00FF".

3. Cross-Base Conversion: BIN2HEX, HEX2BIN, and OCT Functions

You can convert directly between non-decimal systems without first routing calculations through a decimal intermediary:

# Convert 8-bit binary directly to Hexadecimal
=BIN2HEX(10101111)

# Result: "AF"

# Convert Hexadecimal to Binary with 8-place padding
=HEX2BIN("2B", 8)

# Result: "00101011"

Managing Technical Limits and Errors

The 10-Character (512 Decimal) Limit in Binary Functions

Excel’s binary conversion functions (DEC2BIN, BIN2DEC, BIN2HEX) are strictly constrained to 10 bits (numbers between -512 and 511). Attempting to convert decimal 1024 with DEC2BIN(1024) will trigger a #NUM! error.

Workaround for Large Binary Numbers: For numbers exceeding 512, split the calculation into bytes using INT and MOD functions, or use Hexadecimal as an intermediary (since HEX2DEC supports up to 40-bit values).

Common Errors

  • #NUM! Error: Occurs when the input number exceeds the allowed range for that base, or when the requested places argument is smaller than the required number of digits.
  • #VALUE! Error: Occurs when the input text contains invalid digits for the specified radix (for example, supplying =BIN2DEC(102) fails because digit 2 is illegal in binary, or =HEX2DEC("1G") fails because letter G is invalid in hexadecimal).

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.