BCD

Synopsis

HELP:   Binary coded decimal (BCD) number
TYPE:   OBJECT
SYNTAX: BCD(SIGNED,TYPE=UNPACKED/PACKED/ZONED,ZONE=ANY/ASCII/EBCDIC)

Description

Reads a binary-coded decimal (BCD) representation of an integer number, where each decimal (base 10) digit is encoded in a 4 or 8 bit value. The result is an FL5-internal neutral integer representation which can be converted to any of the supported target integer representations by a corresponding write converter.

This converter supports multiple formats of BCD numbers. The parameter TYPE must be set to the correct BCD format of the input number. The following formats are supported:

BCD numbers can be signed or unsigned. If the SIGNED flag is specified, read numbers are treated as signed. Without the flag, numbers are treated as unsigned BCD. Unsigned BCD numbers can only have positive values. The sign is part of the BCD number. Its specific representation depends on the BCD type:

The hexadecimal values 0xB and 0xD indicate a negative sign. 0xA, 0xC, 0xE and 0xF sign values are treated as positive numbers. Sign values of 0x0 through 0x9 are illegal. For type ZONED, these sign values only apply for BCD numbers in EBCDIC zone format, i.e. the upper zone nibble is set to 0xF. If the zone is in ASCII format (0x3), the positive sign value is 0x3, the negative sign value is 0x7 and all other values are illegal. So, the decimal number -123 in zoned BCD with an EBCDIC zone is 0xF1F2D3. With an ASCII zone, the same number is stored as 0x313273.

The parameter ZONE is relevant only if TYPE=ZONED and specifies whether the zone is in ASCII or EBCDIC format. This is mainly relavant for interpreting the sign correctly as described in the paragraph above. If not specified, the zone is system-dependent (i.e. EBCDIC on EBCDIC machines, ASCII otherwise).

Arguments