Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Comp fields storage in memory

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

New User


Joined: 10 Jun 2005
Posts: 1

PostPosted: Fri Jun 10, 2005 11:53 am    Post subject: Comp fields storage in memory
Reply with quote

Hi all,

If i have a field PIC 9(8) comp .... having value '4020722' , how will it be stored in memory..... will it be in its binary form i.e. 1111 1010 1011 0011 1110 0010 or something else.
I need to write a Conversion Program in C++ that will convert an ASCII number to EBCDIC comp value. Can someone help me with this.
Thanks in advance.
Back to top
View user's profile Send private message

Allu

New User


Joined: 08 Jun 2005
Posts: 4

PostPosted: Fri Jun 10, 2005 5:30 pm    Post subject: Re: Comp fields storage in memory
Reply with quote

Hi Talent.......

What you guessed is correct, It stores in Binary only.

Actually, BINARY, COMP, and COMP-4 are synonyms on all platforms.
Binary format numbers occupy 2, 4, or 8 bytes of storage. If the PICTURE clause specifies that the item is signed, the leftmost bit is used as the operational sign. A binary number with a PICTURE description of four or fewer decimal digits occupies 2 bytes; five to nine decimal digits, 4 bytes; and 10 to 18 decimal digits, 8 bytes. Binary items with nine or more digits require more handling by the
compiler.

Thanks
Allu.
Back to top
View user's profile Send private message
Allu

New User


Joined: 08 Jun 2005
Posts: 4

PostPosted: Fri Jun 10, 2005 5:34 pm    Post subject: Re: Comp fields storage in memory
Reply with quote

Hi Talent.......

What you guessed is correct, It stores in Binary only.

Actually, BINARY, COMP, and COMP-4 are synonyms on all platforms.
Binary format numbers occupy 2, 4, or 8 bytes of storage. If the PICTURE clause specifies that the item is signed, the leftmost bit is used as the operational sign. A binary number with a PICTURE description of four or fewer decimal digits occupies 2 bytes; five to nine decimal digits, 4 bytes; and 10 to 18 decimal digits, 8 bytes. Binary items with nine or more digits require more handling by the
compiler.

Thanks
Allu.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jun 13, 2005 7:41 am    Post subject:
Reply with quote

Hi Guys,

Here's what I get for the binary value of dec 4020722:

0011 1101 0101 1001 1111 0010

What Allu says about the sign is correct but can be misleading. A negative number is represented as the "twos complement" of the positive.

The "twos complement" calculation process follows:

Change every bit in the field containing the pos number to its complement, i.e. ones to zeros, zeros to ones. Add 1 to the low order bit.

Some examples:

A binary 1 is 0000 0001 Its negative is 1111 1111
A binary 2 is 0000 0010 Its negative is 1111 1110

If these values were in 4 byte fields the positive's zeros would extend to the left filling the field, as you know.

However, the negative's ones would extend to the left filling the field.
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 sharing PLI storage Pedro PL/I & Assembler 2 Mon Oct 16, 2017 10:11 pm
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Iterative use of a REXX script causin... bryonyh CLIST & REXX 4 Fri Jul 28, 2017 12:52 pm
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us