DIGIT( ) function

Returns the upper or lower digit of a specified Packed data type byte.

Syntax

DIGIT(byte_location, position)

Parameters

byte_location

Numeric. The byte position in the record.

position

Numeric constant. Specify 1 to return the upper half of the byte, or 2 to return the lower half of the byte.

Output

Numeric.

Remarks

This function separates individual halves of a byte, and returns the value of the byte specified in the position parameter as a digit between 0 and 15.

You can use the function to access individual half-bytes. This is required if you work with applications that use half-byte-aligned packed fields, such as Unisys applications.

Examples

A packed field with the value 123.45 (00 12 34 5C), containing two decimals, and starting in byte position 10, appears in the data record in the following format:

  Byte 10 Byte 11 Byte 12 Byte 13
UPPER(1) 0 1 3 5
LOWER(2) 0 2 4 C

The following example uses the DIGIT( ) function to find the digit that appears in the 12th position in the upper half of the byte.

DIGIT(12, 1)

returns 3.

The following example uses the DIGIT( ) function to find digit that appears in the 12th position in the lower half of the byte.

DIGIT(12, 2)

returns 4.



(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback