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
here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1 PIC X(8) VALUE IS 'A1B2C3D4' but i need to have A2,A3 as ABCD & 1234 repectively...... A2 = ABCD A3 = 1234 Can you please explain me what are the different ways to do it?
What is amode(31)
what is the difference between COBOL2 AND COBOL390?
What is length is cobol?
How are the next sentence and continue different from each other?
How do you get the data to code the BMS macro?
What is the default value(s) for an initialize and what keyword allows for an override of the default?
how do you reference the variable unblock file formats from cobol programs
In which area will you utilize 88 level items in cobol?
Which is the default, TEST BEFORE or TEST AFTER for a PERFORM statement?
i made it to stage 3 of an interview process wednessday they will quiz my knowledge again face to face for an analyst role recruiter said it will be based on Business requirements system is cobol and good ideas what they might ask etc
Write a cobol program making use of the redefine clause.
How you can read the file from bottom?
What is report-item in COBOL?
What are the pertinent COBOL commands?