View previous topic :: View next topic
|
Author |
Message |
somnath
New User
Joined: 21 Mar 2005 Posts: 18 Location: India
|
|
|
|
Hi All,
I have a field B (Pic 9(9)V99) which redifines field A (Pic X(11)). Now A contains spaces. I am moving field B to another field C (Pic 9(9)V99). C is being populated with 0. How can it be possible?
Thanks & Regards,
Somnath. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Somnath,
This is due to an idiosyncrasy of COBOL and ZONED DECIMAL numbers.
First, a definition of ZONED DECIMAL (External Decimal) from the IBM Manual:
External Decimal Items are sometimes referred to as zoned decimal items. Each digit of a number is represented by a single byte. The 4 high-order bits of each byte are zone bits; the 4 high-order bits of the low-order byte represent the sign of the item. The 4 low-order bits of each byte contain the value of the digit.
The zone bits on all but the sign zone of zoned decimal numbers is hex ?F? (all bits on). The zone bits of the sign zone are as follows. Unsigned = hex ?F?, positive = hex ?C?, negative = ?D?.
So, a zoned decimal unsigned number 00000 = hex x?F0F0F0F0F0?. The hex representation of 5 spaces is x?4040404040?.
As you can see, the only difference between these two variables is the zone bits. When you moved A to C, COBOL moved x?4040404040? to C and then because C is defined as unsigned, set the sign zone to hex ?F? so you now have x?40404040F0?. You could use this variable in any way; the zones of all but the sign are ignored. |
|
Back to top |
|
|
somnath
New User
Joined: 21 Mar 2005 Posts: 18 Location: India
|
|
|
|
Thanks a lot Dave.
Somnath. |
|
Back to top |
|
|
Sasi Kiran Patha Warnings : 2 New User
Joined: 19 Nov 2006 Posts: 73 Location: Hyederabad
|
|
|
|
An addition to the above query by somnath,
When i move A to C and display C it is displayed as 000
when i move A to B and display C it is displayed as 0.
why is the displatity in the number of zero s that are displayed for the
same variable C. How does it actually matter any where if at all.
Regrds,
Sasi Patha. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please post the data division (the fields) and procedure division (the moves and displays) code that produced your 000/0 output. |
|
Back to top |
|
|
|