DIGIT( ) function

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

Syntax

DIGIT(byte_location, position)

Parameters

Name Type Description
byte_location numeric

The byte position in the record.

position numeric

The digit to return:

  • specify 1 to return the upper half of the byte
  • specify 2 to return the lower half of the byte

Output

Numeric.

Examples

Basic 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

Returns 3 (finds the digit that appears in the 12th position in the upper half of the byte):

DIGIT(12, 1)

Returns 4 (finds digit that appears in the 12th position in the lower half of the byte):

DIGIT(12, 2) 

Remarks

How it works

DIGIT( ) 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.

When to use DIGIT( )

Use DIGIT( ) to access individual half-bytes. This is required if you work with applications that use half-byte-aligned packed fields, such as Unisys applications.

ACL Scripting Guide 14.1