Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Moving Spaces to a numeric field?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
somnath

New User


Joined: 21 Mar 2005
Posts: 18
Location: India

PostPosted: Fri Jan 12, 2007 8:06 pm    Post subject: Moving Spaces to a numeric field?
Reply with quote

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
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jan 12, 2007 9:46 pm    Post subject: Re: Moving Spaces to a numeric field?
Reply with quote

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
View user's profile Send private message
somnath

New User


Joined: 21 Mar 2005
Posts: 18
Location: India

PostPosted: Tue Jan 16, 2007 11:29 am    Post subject:
Reply with quote

Thanks a lot Dave.

Somnath.
Back to top
View user's profile Send private message
Sasi Kiran Patha
Warnings : 2

New User


Joined: 19 Nov 2006
Posts: 73
Location: Hyederabad

PostPosted: Sat Jan 20, 2007 12:59 pm    Post subject: Re: Moving Spaces to a numeric field?
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Jan 21, 2007 6:23 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us