Binary-coded decimal: Difference between revisions

Content deleted Content added
{{anchor|Zoned BCD}}Zoned decimal: 6-bit on older machines; sign
Line 434:
 
=={{anchor|Zoned BCD}}Zoned decimal==
Some implementations, for example [[IBM]] mainframe systems, support '''zoned decimal''' numeric representations. Each decimal digit is stored in one 8-bit<ref group=nb>6-bit for older machines.</ref> byte, with the lower four bits encoding the digit in BCD form. The upper four<ref group=nb>Two for older machines.</ref> bits, called the "zone" bits, are usually set to a fixed value so that the byte holds a character value corresponding to the digit, or to values representing plus or minus. EBCDIC<ref group=nb>The values shown for {{base|C0|16}} and {{base|D0|16}} are for code page 037.</ref> systems use a zone value of {{base|1111|2}} ({{base|F|16}}), yielding {{base|F0|16}}-{{base|F9|16}}, the codes for "0" through "9", a zone value of {{base|1100|2}} ({{base|C|16}}) for positive, yielding {{base|C0|16}}-{{base|C9|16}}, the codes for "A{" through "I" and a zone value of {{base|1110|2}} ({{base|D|16}}) for negative, yielding {{base|D0|16}}-{{base|D9|16}}, the codes for the characters "J}" through "R". Similarly, ASCII systems use a zone value of 0011 (hex 3), giving character codes 30 to 39 (hex).
 
For signed zoned decimal values, the rightmost (least significant) zone nibble holds the sign digit, which is the same set of values that are used for signed packed decimal numbers (see above). Thus a zoned decimal value encoded as the hex bytes F1 F2 D3 represents the signed decimal value −123: