IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How binary is stored as COMP variable


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rohin

New User


Joined: 29 Apr 2005
Posts: 21
Location: Gurgaon, India

PostPosted: Thu Jun 07, 2007 3:20 pm
Reply with quote

Hi,

I didnot understand how binary is stored as COMP variable?
S9(4) COMP is stored in 2 bytes.
How is value 32768 or -32767 stored as COMP, as in how will it look like if I turn HEX ON?

THanks
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Jun 07, 2007 3:47 pm
Reply with quote

Actually +32768 is one too big to fit and -32767 is one less than the negitive max. the real limits are -32768 through +32767 which would be:
..
80
00
through
..
7F
FF
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Jun 07, 2007 5:55 pm
Reply with quote

COBOL won't let you store anything bigger than +/- 9999 in an S9(4) COMP, as the replication numver = 4. (Although some 5-digit numbers can be stored in a halfword (2 bytes), not all can.)

You need S9(5) COMP thru S9(9) COMP, which allocates a fullword (4 bytes), and can store the max number of digits you specify.
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Jun 08, 2007 4:42 pm
Reply with quote

I think the following link will not be amiss here ibmmainframes.com/viewtopic.php?t=19569&highlight=comp5

S9(04) COMP-5 can accomodate five digit data as opposed to S9(04)COMP
Pray be careful in using COMP-5 as it has some machine dependency.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top