BCDTOINT

The BCDTOINT function converts an item from BCD (binary coded decimal) format to integer format.

The binary value that is returned has a form native to the machine on which the map is being run.

Syntax:
BCDTOINT (single-text-expression , single-integer-expression)
Meaning:
BCDTOINT (BCD_item_to_convert , length_of_output)
Returns:
A single-binary-number

BCD_item_to_convert is converted from BCD (binary coded decimal) format to its integer value.

Numbers in BCD format have two decimal digits in each byte. Each half-byte, therefore, can contain a binary value from 0000 (which represents the digit 0) through 1001 (which represents the digit 9). Based on this definition, the following behavior applies:

  • If any half-byte of the BCD number contains the binary values 1101 or 1111, that half-byte is ignored.
  • If any half-byte contains the binary values 1010, 1011, 1100, or 1110, the output of the function is "none".

The length of the output binary number is specified by length_of_output. The length must be 1, 2, or 4. If it is any other value, the length is assumed to be 2.

BCDTOINT returns a binary value of the form native to the machine on which the map is being run. The value can therefore be used in arithmetic operations or compared to other numeric values. It should not be used for bit manipulations, because the order of the bytes in the number is dependent on the operating system on which the map is being run. For example, on a personal computer, the low-order byte is first, while on a mainframe, the high-order byte is first.

Examples

  • BCDTOINT ( bcdAmount Field , 2 )

    If the bcdAmount Field contains x'37' in BCD format, this example returns the integer value of 37.

Related functions

  • BCDTOTEXT
  • BCDTOHEX
  • TEXTTOBCD