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


Please Help Members By Posting Answers For Below Questions

How you can read the file from bottom?

654


I have program P1 which calls file F1 which has 100 records and following structure 001 .................. 002 .................. 003 .................. 098 .................... 099 ................... 100 .................... Now I want to read these files and write these records in file F2 in following manner. 001 ...... 051 ..... 002 ...... 052 ..... 003 ...... 053 ..... .......... ....... .......... ....... .......... ....... 048 ........ 098 ...... 049 .......... 099 ....... 050 .... 100 ......

10554


What are declaratives and what are their uses in cobol?

701


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

755


What is the use of intialize verb?

738






Difference between array and sub-script ?

1156


Explain the configuration section of a cobol program with examples of syntax.

650


how can i see junk values in dclgen or in hostvariable of comp ?

2536


I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?

1796


Differentiate between structured cobol programming and object-oriented cobol programming.

661


What is the default value(s) for an initialize and what keyword allows for an override of the default?

687


What is the LINKAGE SECTION used in COBOL?

885


What is inspect in cobol ?

793


Describe the cobol database components?

672


What is the local-storage section?

673