HEXTOBIGINT Function [Data Type Conversion]

Returns the BIGINT equivalent of a hexadecimal string.

Syntax

HEXTOBIGINThexadecimal-string )

Parameters

Parameter

Description

hexadecimal-string

The hexadecimal value to be converted to a big integer (BIGINT). Input can be in the following forms, with either a lowercase or uppercase “0x” in the prefix, or no prefix:
0xhex-string
0Xhex-string
hex-string

Examples

The following statements return the value 4294967287:

SELECT HEXTOBIGINT ( '0xfffffff7' ) FROM iq_dummy
SELECT HEXTOBIGINT ( '0Xfffffff7' ) FROM iq_dummy
SELECT HEXTOBIGINT ( 'fffffff7' ) FROM iq_dummy

Usage

The HEXTOBIGINT function accepts hexadecimal integers and returns the BIGINT equivalent. Hexadecimal integers can be provided as CHAR and VARCHAR value expressions, as well as BINARY and VARBINARY expressions.

The HEXTOBIGINT function accepts a valid hexadecimal string, with or without a “0x” or “0X” prefix, enclosed in single quotes.

Input of fewer than 16 digits is assumed to be left-padded with zeros.

For data type conversion failure on input, an error is returned unless the CONVERSION_ERROR option is set to OFF. When CONVERSION_ERROR is OFF, invalid hexadecimal input returns NULL.

See Reference: Statements and Options > Database Options > Alphabetical List of Options > CONVERSION_ERROR Option [TSQL].

An error is returned if a BINARY or VARBINARY value exceeds 8 bytes and a CHAR or VARCHAR value exceeds 16 characters, with the exception of the value being appended with ‘0x.’

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related reference
BIGINTTOHEX Function [Data Type Conversion]
HEXTOINT Function [Data Type Conversion]
INTTOHEX Function [Data Type Conversion]