Previous Topic: CPUTIME()Next Topic: DASD()


D2P()

This function converts a REXX-format whole number into IBM packed-decimal format. This form is frequently used to store decimal numbers with two digits per byte.

Syntax

pdec = D2P(number,bytes,[resultform])

Parameters

pdec

Packed decimal number. Each byte contains two decimal digits, except the right-most byte, which can contain a sign digit (hexadecimal F for positive, B for negative) in the right half of the byte. The third argument controls the presence of the sign.

number

Whole number. You can include a leading sign.

bytes

Number of bytes occupied by the returned packed-decimal number. Specify a value from 1 to 8 (inclusive). Truncation and padding are performed on the left.

resultform

Format for the result:

SIGN

Indicates that a hexadecimal F (positive) or B (negative) occupies the right-most 4 bits of the result.

NOSIGN

Indicates that the packed-decimal number occupies the entire result string and no indication of sign is present.

Default: SIGN

Return Codes

101 - 103

ARG n MISSING OR INVALID

Example

/*   Pack a Julian date to store in ISPF statistics format */
/*   date as year and day */
parse arg year '.' day
/* Standard form:yyddd*/
julian = right(year,2,'0')||right(day,3,'0')
 /* packed format (4 bytes): 00 yy dd dF*/
pdec = d2p(julian,4,'sign')