Data Transformation Engine Functions and Expressions Reference Guide

Chapter 3 - Function Reference BCDTOHEX
Functions and Expressions Reference Guide
66
BCDTOHEX
The BCDTOHEX function converts an item from BCD (binary coded decimal) format
to hex (hexadecimal) format. The binary value that is returned always has the
high-order byte first, regardless of the platform.
Syntax
BCDTOHEX (single-text-expression, single-integer-expression)
Meaning
BCDTOHEX (BCD_item_to_convert, length_of_output)
Returns
This function returns a single-binary-bytestream.
The input argument is converted from BCD format to its binary 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,
! 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 argument is specified as the value of the second input
argument. The length must be 1, 2, or 4. If it is any other value, the length is
assumed to be 2.
BCDTOHEX returns a binary value whose high-order byte comes first,
regardless of the platform. This is useful for testing a specific bit position for a
specific value.
Example
TESTON (BCDTOHEX ( ProcessIndicator, 2) 10)
Tests for the x‘0040’ bit in a two-byte result.
Note This same test, using BCDTOINT on a PC, tests the x‘4000’ bit.