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

Maximum value of a comp-3 variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Mon Sep 10, 2007 2:56 pm
Reply with quote

Hi,

What can be the maximum value of a comp-3 variable and how that variable can be declared.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Sep 10, 2007 3:01 pm
Reply with quote

Vivek,

Did you refer any manaul? From the QW -

Quote:
PACKED-DECIMAL
Specified for internal decimal items. Such an item appears in
storage in packed decimal format. There are two digits for each
character position, except for the trailing character position,
which is occupied by the low-order digit and the sign. Such an
item can contain any of the digits 0 through 9, plus a sign,
representing a value not exceeding 18 decimal digits.

The sign representation uses the same bit configuration as the
4-bit sign representation in zoned decimal fields. For details,
see the Enterprise COBOL Programming Guide.
Back to top
View user's profile Send private message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Mon Sep 10, 2007 3:07 pm
Reply with quote

Thanks Murali,

So what you mean is we can declare a COMP-3 variable as s9(18)v9(any number less than 18) comp-3.

Do correct me if i am wrong.

QW? If you can expand on this...
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 3:10 pm
Reply with quote

viveksingal wrote:
What can be the maximum value of a comp-3 variable and how that variable can be declared.

If the ARITH(COMPAT) compiler option is in effect: 18 digits or S9(18)...
If the ARITH(EXTEND) compiler option is in effect: 31 digits or S9(31)...
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Sep 10, 2007 3:12 pm
Reply with quote

Vivek,
Quote:
QW? If you can expand on this...

QUICK REFERENCE available in MF.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 3:17 pm
Reply with quote

viveksingal wrote:
So what you mean is we can declare a COMP-3 variable as s9(18)v9(any number less than 18) comp-3.
No, tha max number of total digits is 18 or 31.....

Quote:
Do correct me if i am wrong.
Consider yourself corrected.... icon_wink.gif
Back to top
View user's profile Send private message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Mon Sep 10, 2007 3:39 pm
Reply with quote

Thanks guys,

Now comes my actual problem... I want to multipy two values with these declarations ...

Pic S9(11)V9(6) usage COMP-3 and S9(10)V9(2) usage COMP-3

so to capture the result of this multiplication i have to declare a variable in this manner (considering values is maximum in both the input variables)... S9(21)V9(8) usage COMP-3 ...

and my compiler options support declaration of variable with maximum as 18....

How can i handle such a case now ...
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 3:42 pm
Reply with quote

viveksingal wrote:
and my compiler options support declaration of variable with maximum as 18....
Simple, add ARITH(EXTEND) to your compile....
Back to top
View user's profile Send private message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Mon Sep 10, 2007 5:08 pm
Reply with quote

But i am in need of a solution without changing the Compile options ...
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 5:20 pm
Reply with quote

viveksingal wrote:
But i am in need of a solution without changing the Compile options ...
Bull Pucky..... icon_rolleyes.gif
Either your results are always going to be accurate or not, what is the requirement? Accuracy or close to accurate?
Back to top
View user's profile Send private message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Mon Sep 10, 2007 5:50 pm
Reply with quote

It has to be accurate ...
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 5:59 pm
Reply with quote

viveksingal wrote:
It has to be accurate ...
If it has to be accurate and the number of digits is greater than 18, you will have to use ARITH(EXTEND)......
One or the other, accurate or just close to accurate......
Back to top
View user's profile Send private message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Mon Sep 10, 2007 6:08 pm
Reply with quote

Ok, but when we try to compile it via Endevor ... we are not able to find the ARITH parameter any where ... even when the Compile JCl is JSCANED ... we are not able to find ARITH parameter ....

Any idea on where we have to provide this parameter ....
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 6:24 pm
Reply with quote

You can put the ARITH in a CBL (PROCESS) statement before the ID Division statement....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

PostPosted: Mon Sep 10, 2007 6:28 pm
Reply with quote

Hello,

When your compile is submitted, there are most likely parameters supplied in the compile PARM. You would need to add ARITH to those parms.

If you need to change how the jcl is created, i'd suggest you talk with the people who support Endevor on your system.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Mon Sep 10, 2007 11:39 pm
Reply with quote

Doesn't COBOL support floating point like PL/1 does?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Sep 11, 2007 12:27 am
Reply with quote

Yes, COMP-1 & 2, but that still will not guarantee al the digits - another case of almost accurate....grin.....
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Tue Sep 11, 2007 2:42 pm
Reply with quote

In that case split the digits and the decimals, calculate and join afterwards
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Sep 11, 2007 2:44 pm
Reply with quote

I don't think that will work for multiplication and division.....
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Wed Sep 12, 2007 1:46 am
Reply with quote

Yep........I did it in the last century using PL/1 calculating interest over big money. Just deal with p- and q-parts.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Sep 12, 2007 2:05 am
Reply with quote

Bitneuker wrote:
Yep........I did it in the last century using PL/1 calculating interest over big money. Just deal with p- and q-parts.
I don't know, there was a similar thread a while back and I too thought that it could be gotten around....But after trying with extreme values, the number of digits exceeded the available number and precision was lost.....
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Wed Sep 12, 2007 10:32 am
Reply with quote

thanks for information.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Sep 12, 2007 9:30 pm
Reply with quote

Bitneuker wrote:
Yep........I did it in the last century using PL/1 calculating interest over big money. Just deal with p- and q-parts.
I stand corrected, had a little think time and came up wit a solution along your lines........
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Sep 13, 2007 6:06 pm
Reply with quote

CICS Guy wrote:
I stand corrected, had a little think time and came up wit a solution along your lines........


Appriciate that icon_wink.gif
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 DECIMAL HOST VARIABLE OR PARAMETER 14... DB2 6
No new posts How to add 2 digits to COMP-3 file? DFSORT/ICETOOL 11
No new posts FILE STATUS - 39 ON VARIABLE LENGTH V... COBOL Programming 2
No new posts Unable to display comp variable COBOL Programming 4
No new posts IWS/TWS build dinamic or variable APp... IBM Tools 0
Search our Forums:

Back to Top