ZD: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(Created page with "The '''ZD (zoned decimal) format specification''' is usually used for maximum portability with other computers. It can be used only with FORM statements for internal and e...")
 
No edit summary
 
Line 14: Line 14:
;Output would be as follows:
;Output would be as follows:


   2310231)
   2310231


<noinclude>
<noinclude>
[[Category:Format Specifications]]
[[Category:Format Specifications]]
</noinclude>
</noinclude>

Latest revision as of 15:14, 7 August 2013

The ZD (zoned decimal) format specification is usually used for maximum portability with other computers. It can be used only with FORM statements for internal and external files.

The ZD format specification is now valid for use with display files (PRINT). This was done mainly for S/36 compatibility.

Input characteristics

The decimal point is not stored with a ZD-formatted number. (It is similarly only implied with PD- and B- formatted numbers.) Therefore, the same format specification must be used to retrieve the number as was used to write it. Reading a field with a ZD 5 that was written with a ZD 5.2 results in a number 100 times larger than was written.

Output Characteristics

When ZD is used for numeric output to disk, the number is rounded to the specified number of decimal positions before writing. Each digit is stored in its own byte and has the values 0-9. The last byte also contains the sign, and if the number is negative has the values ), J, K, L, M, N, O, P, Q, R which correspond to -0 through -9, respectively. For example:

00010 WRITE #1,USING 20: 23.1,-23.1
00020 FORM 2*ZD 4.2
Output would be as follows
 2310231