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
 

 

Numeric values for S9(8) COMP.

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

New User


Joined: 12 Jul 2006
Posts: 24

PostPosted: Wed Feb 06, 2008 12:18 pm    Post subject: Numeric values for S9(8) COMP.
Reply with quote

Hi,

I need to know the maximum numeric value which can be stored in a S 9(8) COMP variable. I guess it should be in 10 digits, but need the max value.

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

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Feb 06, 2008 2:36 pm    Post subject:
Reply with quote

check the manual. - the document describing your version of cobol. links at the top of this page

Quote:

I guess it should be in 10 digits, but need the max value.


while you are there, read up on how variables are defined.
pic 9(8) says 8 digits.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Feb 06, 2008 4:33 pm    Post subject:
Reply with quote

S9(5) through S9(9)
Binary full-word (4 bytes)
-2,147,483,648 through +2,147,483,647
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Thu Feb 07, 2008 1:04 am    Post subject:
Reply with quote

But as dbz... points out, although a fullword is allocated, COBOL enforces your PIC - length and sign.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Feb 07, 2008 1:26 am    Post subject:
Reply with quote

Phrzby Phil wrote:
COBOL enforces your PIC - length and sign.


Depending on your version and your compiler options.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Thu Feb 07, 2008 2:10 am    Post subject:
Reply with quote

Craq -

Are you saying that there are COBOL's that will let me store and use a 6-digit value in a PIC 9(5), whether display, comp, or comp-3?

wow
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Thu Feb 07, 2008 2:10 am    Post subject:
Reply with quote

Correction: of course only COMP is in question - sorry about the display and comp-3 part.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Feb 07, 2008 6:02 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
Are you saying that there are COBOL's that will let me store and use a 6-digit value in a PIC 9(5)
Check out the 2.4.52 TRUNC option in the ECOBOL Programming Guide.....
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Thu Feb 07, 2008 9:28 pm    Post subject:
Reply with quote

I've checked the link, and I see that there are certain proviso's, e.g.:

Quote:
Use the TRUNC(OPT) option only if you are sure that the data being moved into the binary areas will not have a value with larger precision than that defined by the PICTURE clause for the binary item. Otherwise, unpredictable results could occur. This truncation is performed in the most efficient manner possible; therefore, the results will be dependent on the particular code sequence generated. It is not possible to predict the truncation without seeing the code sequence generated for a particular statement


So one shouldn't use this to cheat the compiler on the digit length if larger values are possible.

I'd expect serious justification for using this feature, like a tight loop executed 100 million times.
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 Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm


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