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 can you get the ksds file records into your cobol program?

846


Which is not true about evaluate statement

2099


What is cobol?

950


2 input fles: 2 flat files, with different number of records. both are having unique key for each record and already sorted in ascending order . match these files using unique key and in output only matching key value has to be written. please procide cobol logic

2362


Define cobol?

1073


how to refer the data field?

1994


What are the various section in data division and briefly explain them.

914


what is search and searchall?what is the diffrence between them?give an best example?

6194


Write the code to count the sum of n natural numbers.

932


How do you define a variable of comp-1 and comp-2?

914


Name the sections present in data division.

908


Difference between cobol and cobol-ii?

947


What is rmode(24)

902


I have File 1 occurs 5 times with Employee-ID,Employee-Name,Employee-Dept (EEE and MECH). I have File 2 occurs 10 times with Employee-ID,Employee-Name,Employee-Dept (EEE,CIVIL,CHEMICAL and MECH). In FIle 1 and FIle 2 , for matching Employee-DEPT (Only MECH) , we need to move entire records from file1 to file 2. We should not use 2D array. Your help is needed here.

1350


How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.

3950