Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, I would like to know what is the maximum and minimum value that can be stored in the following declarations and how? 1. VAR1 PIC S9(03) COMP-3. 2. VAR2 PIC S9(04) COMP. 3. VAR3 PIC 9(03) COMP-3. 4. VAR4 PIC 9(04) COMP. It would be of great help, if anybody can answer to me on this. Thanks, Sudhakar
Post Follow-up to this messageRoger wrote: > Hi, > > I would like to know what is the maximum and minimum value that can be > stored in the following declarations and how? > > 1. VAR1 PIC S9(03) COMP-3. > 2. VAR2 PIC S9(04) COMP. > 3. VAR3 PIC 9(03) COMP-3. > 4. VAR4 PIC 9(04) COMP. > > It would be of great help, if anybody can answer to me on this. > > Thanks, > Sudhakar Assuming IBM mainframe COBOL, which seems likely given the COMP-3, which is usually IBM packed decimal, making COMP likely to be IBM binary: 1. Integer values from -999 through +999. 2. Depends on the TRUNC compile-time option, but integer -9999 through +9999 for sure, possibly -32767 through +32767. 3. Integer values from 000 through 999. 4. Depends on the TRUNC compile-time option, but 0000 through 9999 for sure, possibly 00000 through 65535. My answer for #2 is debatable, due to two's complement of the lowest negative number. I hope that helps! -- http://arnold.trembley.home.att.net/
Post Follow-up to this messageOn 23 May 2004 22:16:30 -0700 sudhakarkreddy@yahoo.com (Roger) wrote: :>I would like to know what is the maximum and minimum value that can be :>stored in the following declarations and how? :>1. VAR1 PIC S9(03) COMP-3. :>2. VAR2 PIC S9(04) COMP. :>3. VAR3 PIC 9(03) COMP-3. :>4. VAR4 PIC 9(04) COMP. :>It would be of great help, if anybody can answer to me on this. Depends on how stored, and depends on compiler options. 1: -999:+999 2: (-32768/7 or -9999):(+32767 or +9999) 3: (-999 or 0):+999 4: (-32768/7 or o):(+32767 or +9999) -- Binyamin Dissen <bdissen@dissensoftware.com> http://www.dissensoftware.com Director, Dissen Software, Bar & Grill - Israel
Post Follow-up to this messageIn article <a2380f6f.0405232116.42ae7c30@posting.google.com>, Roger <sudhakarkreddy@yahoo.com> wrote: >Hi, > >I would like to know what is the maximum and minimum value that can be >stored in the following declarations and how? Please do your own homework. DD
Post Follow-up to this message"Roger" <sudhakarkreddy@yahoo.com> wrote in message news:a2380f6f.0405232116.42ae7c30@posting.google.com... > I would like to know what is the maximum and minimum value that can be > stored in the following declarations and how? > > 1. VAR1 PIC S9(03) COMP-3. > 2. VAR2 PIC S9(04) COMP. > 3. VAR3 PIC 9(03) COMP-3. > 4. VAR4 PIC 9(04) COMP. > Text and graphic tutorial on COBOL data types: http://www.flexus.com/ftp/cobdata.zip -- Michael Mattias Tal Systems, Inc. Racine WI mmattias@talsystems.com
Post Follow-up to this messageArnold Trembley <arnold.trembley@worldnet.att.net> wrote in message news:<t1gsc.21673$fF3.5 57761@bgtnsc05-news.ops.worldnet.att.net>... > Roger wrote: > > Assuming IBM mainframe COBOL, which seems likely given the COMP-3, > which is usually IBM packed decimal, making COMP likely to be IBM binary: > > 1. Integer values from -999 through +999. > 2. Depends on the TRUNC compile-time option, but integer -9999 > through +9999 for sure, possibly -32767 through +32767. > 3. Integer values from 000 through 999. > 4. Depends on the TRUNC compile-time option, but 0000 through 9999 > for sure, possibly 00000 through 65535. > > My answer for #2 is debatable, due to two's complement of the lowest > negative number. > > I hope that helps! Thanks very much!! I still have few questions, in the program i am debugging it is right now able to store 18981 in the S9(04)comp field. So, can you please let me know how do i find out what should be the COMP declaration if i have to store a value of 45000.... Also i heard that in S9(04) we can store a value of up to 65635 eventhough we declared as s9(04) COMP....this is because COMP fields do not care the sign field if it is having positive value... Please clarify... Thanks, Sudhakar
Post Follow-up to this messageAgain - Please tell us the compiler you are using - and if you are on an IBM mainframe, what setting you have for the TRUNC compiler option. Without this information, we really cannot give you an accurate answer. -- Bill Klein wmklein <at> ix.netcom.com "Roger" <sudhakarkreddy@yahoo.com> wrote in message news:a2380f6f.0405242135.13040b61@posting.google.com... > Arnold Trembley <arnold.trembley@worldnet.att.net> wrote in message news:<t1gsc.21673$fF3.557761@bgtnsc05-news.ops.worldnet.att.net>... > > Thanks very much!! > > I still have few questions, in the program i am debugging it is right > now able to store 18981 in the S9(04)comp field. > > So, can you please let me know how do i find out what should be the > COMP declaration if i have to store a value of 45000.... > > Also i heard that in S9(04) we can store a value of up to 65635 > eventhough we declared as s9(04) COMP....this is because COMP fields > do not care the sign field if it is having positive value... > > Please clarify... > > Thanks, > Sudhakar
Post Follow-up to this messageRoger wrote:
> Arnold Trembley <arnold.trembley@worldnet.att.net> wrote in message
> news:<t1gsc.21673$fF3.557761@bgtnsc05-news.ops.worldnet.att.net>...
>
> Thanks very much!!
>
> I still have few questions, in the program i am debugging it is right
> now able to store 18981 in the S9(04)comp field.
>
> So, can you please let me know how do i find out what should be the
> COMP declaration if i have to store a value of 45000....
>
> Also i heard that in S9(04) we can store a value of up to 65635
> eventhough we declared as s9(04) COMP....this is because COMP fields
> do not care the sign field if it is having positive value...
>
> Please clarify...
>
> Thanks,
> Sudhakar
1. Without fussing with the TRUNC option:
01 BigNumber pic 9(9) comp-4.*
01 Filler redefines BigNumber.
02 ignore-me pic x(2).
02 LittleNumber pic x(2).
Move 45000 to BigNumber.
Move LittleNumber to {storage area defined as X(2)}
on return
Move 0 to BigNumber
Move {storage area} to LittleNumber
Move BigNumber to Units-On-Hand (or whatever BigNumber represents)
----
*Assuming comp-4 on your machine is straight binary. With comp-5 on a PC,
the order of "ignore-me" and "LittleNumber" would be reversed.
Post Follow-up to this message"Roger" <sudhakarkreddy@yahoo.com> wrote in message news:a2380f6f.0405242135.13040b61@posting.google.com... > > I still have few questions, in the program i am debugging it is right > now able to store 18981 in the S9(04)comp field. > > So, can you please let me know how do i find out what should be the > COMP declaration if i have to store a value of 45000.... > > Also i heard that in S9(04) we can store a value of up to 65635 > eventhough we declared as s9(04) COMP....this is because COMP fields > do not care the sign field if it is having positive value... > > Please clarify... Did you read the tutorial I sent you to? If you had, you would already know that the maximum "safe and supported" value of *any* COBOL dataname with a USAGE clause other than COMP-1, COMP-2, POINTER or PROCEDURE-POINTER is limited to the number of radix 10 digits defined in the PICTURE clause. i.e., the maximum decimal value for.... LL VAR 1 PIC[TURE] [IS] [S]9(n)V9(m) USAGE COMP| COMP-3 | COM P-4 | COMP-5| DISPLAY |PACKED-DECIMAL | BINARY ...is 'n' decimal digits before the decimal point and 'm' decimal digits after. Period. (There's a "P" you can use to 'scale' these, but it sure does not sound like you are ready for that... besides, in your application it is not necessary). All these replies dealing with the TRUNC option, taking advantage of a particular compiler or piece of hardware, or redefinitions are "tricks" and should not be used in the course of normal COBOL applications programming. If you need to store the decimal value 45000, you may use any PICTURE and USAGE clauses with five (5) or more decimal digits before the decimal point; or you may use COMP-1 or COMP-2 (usually IEEE floats, and I don't recommend the use of these due to the rounding problems inherent in floating point data) -- Michael Mattias Tal Systems, Inc. Racine WI mmattias@talsystems.com
Post Follow-up to this messageOn 24-May-2004, sudhakarkreddy@yahoo.com (Roger) wrote: > I still have few questions, in the program i am debugging it is right > now able to store 18981 in the S9(04)comp field. > > So, can you please let me know how do i find out what should be the > COMP declaration if i have to store a value of 45000.... > > Also i heard that in S9(04) we can store a value of up to 65635 > eventhough we declared as s9(04) COMP....this is because COMP fields > do not care the sign field if it is having positive value... With my mainframe IBM compiler my pre-compiler stores database keys in field s that are too large according to the CoBOL pictures. I use some redefines i n a called routine to actually access those numbers in full. But you're safer to believe in the CoBOL standard. If your picture is S9(0 4), believe it. Now your code will be portable, and it won't matter what compi ler options you have. (If you have a specialized need such as mine, come up wi th a solution similar to mine). If you want to know how much memory your S9(04) number takes up, that is a different story.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.