HEXTOBIGINT function [Data type conversion]

Function

Returns the BIGINT equivalent of a hexadecimal string.

Syntax

HEXTOBIGINT ( hexadecimal-string )

Parameters

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, Sybase IQ returns an error unless the CONVERSION_ERROR option is set to OFF. When CONVERSION_ERROR is OFF, invalid hexadecimal input returns NULL.

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

See also

“CONVERSION_ERROR option [TSQL]”

“BIGINTTOHEX function [Data type conversion]”

“HEXTOINT function [Data type conversion]”

“INTTOHEX function [Data type conversion]”