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.
pdec = D2P(number,bytes,[resultform])
Parameters
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.
Whole number. You can include a leading sign.
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.
Format for the result:
Indicates that a hexadecimal F (positive) or B (negative) occupies the right-most 4 bits of the result.
Indicates that the packed-decimal number occupies the entire result string and no indication of sign is present.
Default: SIGN
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')
Copyright © 2014 CA Technologies.
All rights reserved.
|
|