How is sign stored in Packed Decimal fields and Zoned
Decimal fields?
Answer Posted / dinesh kumar gaddam
Packed Decimal fields (COMP-3):
the sign is stored in the last nibble (4 bits).
If sign S is not used then last nibble will contain X'F'.
If sign S is used and value is positive then it will contain X'C'
if sign S is used and value is negative then it will contain X'D'
Example:
PIC S9(04) COMP-3 VALUE 2345. -> X’02345C’
PIC S9(04) COMP-3 VALUE -2345. -> X’02345D’
PIC 9(04) COMP-3 VALUE 2345. -> X’02345F’
Zoned Decimal fields (DISPLAY):
The data is stored in zoned decimal as:
1 is represented as X’F1’
2 is represented as X’F2’ etc.
If the data is declared as signed S then sign is over punched with numeric value of last byte in zoned decimal.
If the value is positive then last bytes first nibble will be X’C’ instead of X’F’ and if the value is negative then last bytes first nibble will be X’D’ instead of X’F’.
Example:
PIC 9(04) VALUE 1234. -> X’F1F2F3F4’
PIC S9(04) VALUE -1234. -> X’F1F2F3D4’
PIC S9(04) VALUE 1234. -> X’F1F2F3C4’
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
What is perform what is varying?
How to remove the spaces at the end of each record in the output file of variable length, via cobol program?
Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?
Can we change the password using ALTER? anyone tried and changed?
Difference between array and sub-script ?
How to use the same COBOL program in Batch and CICS on lines? explain with an example
if we have " ibm mainframe ",in that how to remove first and last leading space eg:"ibm mainframe" like that the answer we need
What is Pic 9v99 Indicates in COBOL?
) how do u code after getting data?
What are the various section in data division and briefly explain them.
What are the rules of the move verb?
Can you please let me know the centre name of INS certification in Kolkata.
What are 77 levels used for?
What is the use of intialize verb?
how can i see junk values in dclgen or in hostvariable of comp ?