How is sign stored in Packed Decimal fields and Zoned
Decimal fields?
Answer Posted / arjun k r
for packed decimal ,one or more bytes hold a decimal integer, where each of the two nibbles of each byte represent a decimal digit, with the more significant digit in the upper half of each byte, and with leftmost byte (residing at the lowest memory address) containing the most significant digits of the packed decimal value. The lower nibble of the rightmost byte is usually used as the sign flag.
Standard sign values are 1100 (hex C) for positive (+) and 1101 (D) for negative (−).
number −1,234,567 is 7 digits wide and is encoded as:
0001 0010 0011 0100 0101 0110 0111 1101
1 2 3 4 5 6 7 −
For Zoned Decimal, Each decimal digit is stored in one byte, with the lower four bits encoding the digit in BCD form. The upper four bits, called the "zone" bits, are usually set to a fixed value so that the byte holds a character value corresponding to the digit.
For signed zoned decimal values, the rightmost (least significant) zone nibble holds the sign digit.Thus a zoned decimal value encoded as the hex bytes F1 F2 D3 represents the signed decimal value −123:
F1 F2 D3
1 2 −3
Source : Wikipedia
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
How do define dynamic array in cobol. how do you define single dimensional array and multidimensional array in your cobol?
Explain sorting techniques in cobol program? Provide the sort file definition, the sort statement, its syntax and meaning
What are the different rules for performing sort operation?
Difference between array and sub-script ?
What are the different open modes available in cobol?
How many sections are there in data division in COBOL?
What are declaratives and what are their uses in cobol?
For rewrite, why is it mandatory that file needs to be opened?
INREC AND OUTREC? HOW TO SPLIT 5K RECORDS TO DIFFERENT FILES IN A FILE IN COBOL? RESTART IN COBOL-DB2? ISOLATION LEVELS?
How do u write test cases?
How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that
How do you reference the fixed block file formats from cobol programs
Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?
How do you reference the following file formats from cobol programs?
Difference between cobol and cobol-ii?