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

Numeric values for S9(8) COMP.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 3156
Location: Tucson AZ

PostPosted: Wed Feb 06, 2008 4:33 pm
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

Senior Member


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

PostPosted: Thu Feb 07, 2008 1:04 am
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
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

Senior Member


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

PostPosted: Thu Feb 07, 2008 2:10 am
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

Senior Member


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

PostPosted: Thu Feb 07, 2008 2:10 am
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: 3156
Location: Tucson AZ

PostPosted: Thu Feb 07, 2008 6:02 pm
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

Senior Member


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

PostPosted: Thu Feb 07, 2008 9:28 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
Search our Forums:

Back to Top