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


Please Help Members By Posting Answers For Below Questions

How do get the result of your program directly on your pc?

1874


Program A (Normal COBBAT) calling a B Program (DB2COBOL, COBBATDB which is using a VSAM file. its a dynamic call. How we will handle VSAM file decleration in our from JCL from where we are running A PGM. And should we have PLAN for A pGM also. if possible can some one post a sample JCL. Thanks for help in advance.

5049


How do you differentiate between cobol and cobol-ii?

646


How did the release of cobol/370 version 1.3 improve the performance of release 1.1?

634


What is a report item?

733






Can a Search can be done on a table with or without Index?

798


What is the difference between goback, stop run and exit program in cobol?

914


What is the LINKAGE SECTION used in COBOL?

885


How are the next sentence and continue different from each other?

755


A table has two indexes defined. Which one will be used by the SEARCH?

750


What is difference between static and dynamic call in cobol?

767


Why would you use find and get rather than to obtain?

677


How to know whether the module is dynamical or statistical?

649


What is comp-1 and comp-2?

754


What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?

667