Related Function:

The HEX2BIN function converts a hexadecimal number to binary number.

Syntax

=HEX2BIN(number,[places])

Note: Hexadecimal (base 16), decimal (base 10), octal (base 8), and binary (base 2) are the most commonly used numeral systems in engineering and computing. Therefore, Excel has provided functions to convert numeric values to and from each of these systems.

Arguments

Argument Description
number The hexadecimal number you want to convert

  Number cannot contain more than 10 characters
  The most significant bit of number is the sign bit, 40th bit from the right
  The remaining 9 bits are magnitude bits
  Negative numbers are represented using two’s-complement notation
[places] Optional. Defines the number of characters to use

  If [places] is omitted, HEX2BIN uses the minimum number of characters necessary
  If [places] is greater than the minimum, the binary number will be padded out using leading zeros
  [Places] is useful for padding the return value with leading 0s (zeros)

Note: As hexadecimals use the numbers 0-9 and the characters a-f, they should be enclosed in quotation marks when they are supplied to an Excel function, e.g. the hexadecimal 11a should be input as “11a”.

Examples

  A B C
1 Formula Result Notes
2 =HEX2BIN(“1D”) 11101 Converts hexadecimal 1D to binary
3 =HEX2BIN(“F”,8) 00001111 Converts hexadecimal F to binary, with 8 characters, 4 zeros at beginning are “padding”
4 =HEX2BIN(“2”) 10 Converts hexadecimal 2 to binary

Common Function Error(s)

Problem What went wrong
#VALUE! Occurs if the supplied [places] argument is not recognized as a number
#NUM! Occurs if either:

  the supplied number argument is not recognized as a hexadecimal number or contains more than 10 characters
  the resulting binary number requires more places than is specified by the supplied [places] argument
  the supplied [places] argument ≤ 0
#NAME? Occurs when Analysis ToolPak add-in is not enabled