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
 
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: 6968
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: 965
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: 965
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: 965
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: 965
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 Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm

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