








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of fixed point arithmetic and its implementation using the packed decimal format on ibm s/370 mainframes. Topics include a review of ibm s/370 floating point formats, precision requirements for business and scientific applications, and an overview of the packed decimal format. The document also covers the encoding of decimal digits, zoned decimal data, and packed decimal data.
Typology: Study notes
1 / 14
This page cannot be seen from the preview
Don't miss anything!









IBM S/370: Terminology and Notation The IBM 370 is a byte–addressable machine; each byte has a unique address. The standard storage sizes on the IBM 370 are byte, halfword, and fullword. Byte 8 binary bits Halfword 16 binary bits 2 bytes Fullword 32 binary bits 4 bytes. In IBM terminology, the leftmost bit is bit zero, so we have the following. Byte 0 1 2 3 4 5 6 7 Halfword 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Fullword 0 – 7 8 – 15 16 – 23 24 – 31 Comment: The IBM 370 seems to be a “big endian” machine.
Precision Example: Slightly Exaggerated Consider a banking problem. Banks lend each other money overnight. At 3% annual interest, the overnight interest on $1,000,000 is $40.492. Suppose my bank lends your bank $10,000,000 (ten million). You owe me $404.92 in interest; $10,000,404.92 in total. With seven significant digits, the amount might be calculated as $10,000,400. My bank loses $4.92. I want my books to balance to the penny. I do not like floating point arithmetic. TRUE STORY When DEC (the Digital Equipment Corporation) was marketing their PDP– to a large New York bank, it supported integer and floating point arithmetic. At this time, the PDP–11 did not support decimal arithmetic. The bank told DEC something like this: “Add decimal arithmetic and we shall buy a few thousand. Without it – no sale.” What do you think that DEC did?
Precision Example: Weather Modeling Suppose a weather model that relies on three data to describe each point.
Kelvins 1.0 10
millibars 1.0 10
percent in humidity.
Zoned Decimal Data
Packed Decimal Data
Zoned Decimal Data The zoned decimal format is a modification of the EBCDIC format. The zoned decimal format seems to be a modification to facilitate processing decimal strings of variable length. The length of zoned data may be from 1 to 16 digits, stored in 1 to 16 bytes. We have the address of the first byte for the decimal data, but need some “tag” to denote the last (rightmost) byte. The assembler places a “sign zone” for the rightmost byte of the zoned data. The common standard is X’C’ for non–negative numbers, and X’D’ for negative numbers. The format is used for constants possibly containing a decimal point, but it does not store the decimal point. As an example, we consider the string “–123.45”. Note that the format requires one byte per digit stored.
Creating the Zoned Representation Here is how the assembler generates the zoned decimal format. Consider the string “–123.45”. The EBCDIC character representation is as follows. Character – 1 2 3. 4 5 Code 6D F1 F2 F3 4B F4 F The decimal point (code 4B) is not stored. A bit later we shall see the reason for this. The sign character is implicitly stored in the rightmost digit. The zoned data representation is as follows. 1 2 3 4 5 F1 F2 F3 F4 D The string “F1 F2 F3 F4 C5” would indicate a positive number, with digits “12345”.
Example: Addition of Two Packed Decimal Values
30
Fixed Point: Where is the Decimal Point?