How is sign stored in Packed Decimal fields and Zoned
Decimal fields?

Answers were Sorted based on User's Feedback



How is sign stored in Packed Decimal fields and Zoned Decimal fields?..

Answer / kavi

Packed Decimal fields: Sign is stored as a hex value in
the last nibble (4 bits ) of the storage.

Zoned Decimal fields: As a default, sign is over punched
with the numeric value stored in the last bite.

Is This Answer Correct ?    18 Yes 2 No

How is sign stored in Packed Decimal fields and Zoned Decimal fields?..

Answer / escapa

In both sign is stored at last byte but

In PACKED Decimal is at last nibble where as in ZONED decimal sign is stored at higher nibble of last byte

Eg.
+1234 in zoned decimal it will be stored as F1 F2 F3 C4
-1234 in zoned decimal it will be stored as F1 F2 F3 D4

+1234 in PACKED decimal it will be stored as 01 23 4C
-1234 in PACKED decimal it will be stored as 01 23 4D

Is This Answer Correct ?    12 Yes 4 No

How is sign stored in Packed Decimal fields and Zoned Decimal fields?..

Answer / 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

How is sign stored in Packed Decimal fields and Zoned Decimal fields?..

Answer / pradeep

For a Packed decimal:
(a) positive value is stored as,

0653
000F

Here, the value 'F' specifies its a +ve value. Also, 'C' is
also used to store +ve values.

(b) negative value is stored with 'D' instead of 'F'

Is This Answer Correct ?    10 Yes 7 No

How is sign stored in Packed Decimal fields and Zoned Decimal fields?..

Answer / purushothr

sign ll stored in
packed decimal: last bit(comp3)
zoned decimal field: most significan bit(comp)

Is This Answer Correct ?    3 Yes 2 No

How is sign stored in Packed Decimal fields and Zoned Decimal fields?..

Answer / 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

More COBOL Interview Questions

i want to use only first 100 records from a file.plz tell me how to write JCL for this(for read,copy,write operations).plz give me details of all posible JCL utilities?

7 Answers   CTS,


can we redefine 77 level item is it possible

4 Answers   HCL,


IDENTIFICATION DIVISION. PROGRAM-ID. UPDT. AUTHOR.anbu. DATE-WRITTEN. AUG 13. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CMSTR ASSIGN TO CINP1 ORGANIZATION IS INDEXED ACCESS IS SEQUENTIAL RECORD KEY CM2-KEY FILE STATUS IS WS-CMSTR-FST. SELECT CTAB ASSIGN TO CINP2 ORGANIZATION IS ACCESS IS SEQUENTIAL RECORD KEY VSAM-WHSE- KEY FILE STATUS IS WS-CTAB- FST. DATA DIVISION. FILE SECTION. FD CMSTR. COPY RXCYFC20. FD CTAB. COPY AITYWHSE. ************************************************************ ****** *** WORKING STORAGE VARIABLES *** ************************************************************ ****** WORKING-STORAGE SECTION. 01 WS- VARIABLES. 05 WS-EB PIC X(02) VALUE ZEROES. 05 WS-DIV PIC 9(03) VALUE ZEROES. 05 WS-CMF-RECS-REWRITTEN PIC 9(01) VALUE ZERO. *** FILE STATUS VARIABLES *** 05 WS- FILESTATUS. 10 WS-CMSTR-FST PIC 9(02) VALUE ZEROES. 10 WS-CTAB-FST PIC 9(02) VALUE ZEROES. *** END OF FILE VARIABLES *** 05 WS-CMSTR-EOF PIC X(01) VALUE 'N'. 88 WS-CMSTR-EOF-YES VALUE 'Y'. 88 WS-CMSTR-EOF-NO VALUE 'N'. 05 WS-CTAB-EOF PIC X(01) VALUE 'N'. 88 WS-CTAB-EOF-YES VALUE 'Y'. 88 WS-CTAB-EOF-NO VALUE 'N'. **** ERROR VARIABLES **** 05 WC-ABEND-900 PIC 9(03) VALUE 900. 05 WE-ERR-CODE PIC 9(02) VALUE ZEROES. 05 WE-ABEND-CODE PIC 9(03) VALUE ZEROES. ************************************************************ **** ********* PROCEDURE DIVISON ********** ************************************************************ **** PROCEDURE DIVISION. 0000- BEGIN. PERFORM 1000-INITIALISE THRU 1000- EXIT. PERFORM 2000-PROCESS THRU 2000- EXIT UNTIL WS-CMSTR-EOF- YES. DISPLAY 'WS-CMF-RECS-REWRITTEN :' WS-CMF-RECS- REWRITTEN. PERFORM 5000-CLOSE THRU 5000- EXIT. GOBACK. 0000- EXIT. EXIT. 1000- INITIALISE. OPEN I-O CMSTR. EVALUATE WS-CMSTR- FST WHEN 00 WHEN 97 CONTINUE WHEN OTHER DISPLAY 'ERROR IN READING INPUT FILE: ' DISPLAY WS-CMSTR-FST MOVE WS-CMSTR-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END-EVALUATE. OPEN INPUT CTAB. EVALUATE WS-CTAB-FST WHEN 00 WHEN 97 CONTINUE WHEN OTHER DISPLAY 'ERROR IN READING INPUT FILE: ' DISPLAY WS-CTAB-FST MOVE WS-CTAB-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END-EVALUATE. 1000-EXIT. EXIT. 2000-PROCESS. READ CMSTR. EVALUATE WS-CMSTR-FST WHEN 00 CONTINUE WHEN 10 SET WS-CMSTR-EOF-YES TO TRUE GO TO 2000-EXIT WHEN OTHER DISPLAY 'ERROR IN READING INPUT FILE: ' DISPLAY WS-CMSTR-FST MOVE WS-CMSTR-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END-EVALUATE IF CM2-RECORD-TYPE-SOLD-TO MOVE CM2-ENTERING-BRANCH TO WS-EB PERFORM 3000-READ THRU 3000-EXIT UNTIL WS-CTAB-EOF-YES END-IF. 2000-EXIT. EXIT. 3000-READ. MOVE WS-EB TO VSAM-WHSE-CD. MOVE 'WHSE' TO VSAM-WHSE-ID. READ CTAB. EVALUATE WS-CTAB-FST WHEN 00 MOVE WHSE-DIV-CODE TO WS-DIV PERFORM 4000-REWRITE-CMF THRU 4000-EXIT WHEN 10 SET WS-CTAB-EOF-YES TO TRUE GO TO 3000-EXIT WHEN OTHER DISPLAY 'ERROR IN READING TABLE FILE: ' DISPLAY WS-CTAB-FST MOVE WS-CTAB-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END- EVALUATE. 3000- EXIT. EXIT. 4000-REWRITE- CMF. IF WS-DIV = 250 OR 252 MOVE 'F' TO CM2-FREIGHT- TYPE MOVE 1 TO CM2-FREIGHT-THRESHOLD- AMT ADD +1 TO WS-CMF-RECS- REWRITTEN REWRITE CM2-SOLD-TO- RECORD DISPLAY 'RECORD UPDATED' END- IF. * EVALUATE WS-CMSTR- FST * WHEN 00 * CONTINUE * WHEN OTHER * DISPLAY 'FILE NOT UPDATED' * DISPLAY WS-CMSTR- FST * MOVE WS-CMSTR-FST TO WE-ERR-CODE * PERFORM 9999-ABEND-PARA THRU 9999-EXIT * GO TO 4000-EXIT * END-EVALUATE. 4000-EXIT. EXIT. 5000-CLOSE. CLOSE CMSTR CTAB. 5000-EXIT. EXIT. 9999-ABEND-PARA. COMPUTE WE-ABEND-CODE = WC-ABEND-900 + WE-ERR-CODE CALL 'ILBOABN0' USING WE-ABEND-CODE GO TO 5000-CLOSE. 9999-EXIT. EXIT. 5000-CLOSE. CLOSE CMSTR CTAB. 5000-EXIT. EXIT. 9999-ABEND-PARA. COMPUTE WE-ABEND-CODE = WC-ABEND-900 + WE-ERR-CODE CALL 'ILBOABN0' USING WE-ABEND-CODE GO TO 5000-CLOSE. 9999-EXIT. EXIT. //this program is giving maxcc=0, but not updating..

0 Answers  


How many types of sorts are there in cobol?

5 Answers   Cap Gemini,


hi is there any means of deletin a record from a ps usin cobol not using jcl?eg if i am reading a record and if some condition is matched tat particular record must be deletd fom the ps

5 Answers   iNautix,






how to display the dataset information?

2 Answers  


What is report-item in COBOL?

0 Answers   Arigo Infotech,


u have passed sme charecters thru parm parameter in jcl. how do u code in cobol to recieve the values u gave in parm ?

2 Answers   IBM,


What is Alternate Index ? How is it different from regular index ?

2 Answers  


File status must be checked both while opening and reading the file or only while reading the file?

2 Answers  


What is the difference between a binary search and a sequential search what are the pertinent cobol?

0 Answers  


How do you reference the following file formats from cobol programs?

0 Answers  


Categories