View previous topic :: View next topic
|
Author |
Message |
lalitha_gld
New User
Joined: 12 Jul 2006 Posts: 24
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
But as dbz... points out, although a fullword is allocated, COBOL enforces your PIC - length and sign. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Phrzby Phil wrote: |
COBOL enforces your PIC - length and sign. |
Depending on your version and your compiler options. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Correction: of course only COMP is in question - sorry about the display and comp-3 part. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
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 |
|
|
|