[Table of Contents] [docx version]

SpreadsheetML Reference Material - Table of Contents

HEX2BIN

Syntax:

HEX2BIN ( number [ , num-bin-digits ] )

Description: Makes the binary equivalent of number, with the result having num-bin-digits digits.

Arguments:

Name

Type

Description

number

text

A 10-digit hexadecimal number in a string that is to be converted to a binary string. number is not case-sensitive. If number has less than 10 digits, leading zero digits are implied until it has exactly 10 digits. The 10 digits use twos-complement representation with the left-most bit (40th bit from the right) representing the sign bit.

 

num-bin-digits

number

The number of digits in the result, with leading zeros added as necessary. However, if number is negative, num-bin-digits is ignored and the result has 10 digits. If num-bin-digits is omitted, the minimum number of digits is used in the result. num-bin-digits is truncated to an integer.

 

Return Type and Value: text – The binary equivalent of number.

However, if

number is outside the range "FFFFFFFE00" (1111111111111111111111111111111000000000 binary, -512 decimal) to "1FF" (0000000000000000000000000000000111111111 binary, 511 decimal), inclusive, #NUM! is returned.

number contains one or more non-hexadecimal digits, #NUM! is returned.

number contains more than 10 hexadecimal digits, #NUM! is returned.

number needs more digits that num-bin-digits, #NUM! is returned.

num-bin-digits is negative or > 10, #NUM! is returned.

[Example:

HEX2BIN("fE") results in 11111110
HEX2BIN("FFFFFFFFFE") results in 1111111110
HEX2BIN("2") results in 10
HEX2BIN("F",6) results in 001111

end example]