The TEXTTOBCD function converts a text item from decimal digits to BCD (Binary Coded Decimal) format.

TEXTTOBCD ( single-integer-text-expression )
TEXTTOBCD ( text_to_be_converted )
A single BCD-formatted text item

TEXTTOBCD converts text_to_be_converted (which consists of decimal digits) to BCD format. In this format, each byte contains two decimal digits represented as binary numbers. If there is an odd number of decimal digits in the input, the high-order half-byte of the leftmost output byte will contain the decimal value 15 (hex "F").

If anything other than a decimal digit is encountered in the input, TEXTTOBCD returns "none".


  • TEXTTOBCD ( "1234" )

    Returns the hexadecimal value x'1234'

  • TEXTTOBCD ( "123A" )

    Returns "none"

  • TEXTTOBCD ( "123" )

    Returns the hexadecimal value x'F123'

    In this example, the values shown as input ("123") are meant to represent character items in the native character set to the machine on which the map is running. On a personal computer, "123" would contain the ASCII characters for the digits that have the hexadecimal values "31", "32", and "33". The output, described as "the hexadecimal value `F123'", consists of the two binary bytes "F1" and "23".

    On an IBM mainframe the input string would contain EBCDIC characters for the digits that have the hexadecimal values "F1", "F2", "F3", º, but the output would be the same as the personal computer output.

Related functions