Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

COMP and COMP-3 fields
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

Report this thread to moderator Post Follow-up to this message
Old Post
Roger
05-24-04 07:30 AM


Re: COMP and COMP-3 fields

Roger 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/



Report this thread to moderator Post Follow-up to this message
Old Post
Arnold Trembley
05-24-04 07:30 AM


Re: COMP and COMP-3 fields
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
Binyamin Dissen
05-24-04 10:30 AM


Re: COMP and COMP-3 fields
In 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


Report this thread to moderator Post Follow-up to this message
Old Post
docdwarf@panix.com
05-24-04 11:30 AM


Re: COMP and COMP-3 fields
"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




Report this thread to moderator Post Follow-up to this message
Old Post
Michael Mattias
05-24-04 04:30 PM


Re: COMP and COMP-3 fields
Arnold 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

Report this thread to moderator Post Follow-up to this message
Old Post
Roger
05-25-04 07:30 AM


Re: COMP and COMP-3 fields
Again -
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



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
05-25-04 09:30 AM


Re: COMP and COMP-3 fields
Roger 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.



Report this thread to moderator Post Follow-up to this message
Old Post
JerryMouse
05-25-04 01:30 PM


Re: COMP and COMP-3 fields
"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











Report this thread to moderator Post Follow-up to this message
Old Post
Michael Mattias
05-25-04 02:30 PM


Re: COMP and COMP-3 fields
On 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
05-25-04 04:30 PM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:08 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.