Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to add 20 Digits number in Cobol?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
gopinathmk

New User


Joined: 17 Nov 2006
Posts: 15

PostPosted: Tue Jan 20, 2009 3:42 pm    Post subject: How to add 20 Digits number in Cobol?
Reply with quote

How to add 20 Digits number in Cobol?
For Ex:Suppose I have two numbers 10000000000000000000
and 10000000000000000000 and I want to add it.How can I do it in cobol?
SInce Max Allowable Pic Clause in cobol is 9(18).How It can be done?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 20, 2009 4:01 pm    Post subject:
Reply with quote

you could use the ARITH(EXTEND) option.

you can find info in COBOL documentation.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8002
Location: Bellevue, IA

PostPosted: Tue Jan 20, 2009 5:56 pm    Post subject:
Reply with quote

Quote:
SInce Max Allowable Pic Clause in cobol is 9(18).How It can be done?
This is true only if ARITH(EXTEND) isn't being used.
Back to top
View user's profile Send private message
rajulan

New User


Joined: 11 Jan 2008
Posts: 66
Location: India

PostPosted: Tue Jan 27, 2009 12:45 pm    Post subject:
Reply with quote

You can pass the arith(extend) compiler option thru parm parameter. Ohterwise you can code like below....

Process arith(extend),
Identification division.
------
-----
---
stop run.

Thanks,
Rajulan.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Jan 28, 2009 11:51 am    Post subject:
Reply with quote

If you are restricted to an old compiler where the ARITH(EXTEND) option was not yet available, you could split the 20-digit numbers into "left" and "right" halves, add the right halves together, carry (if necessary) to the left halves, add the left halves, then concatenate the halves back together into your 20-digit number. Of course, since you are limited to 18 digits, you'd need to define that 20-digit number as alphanumeric.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jan 28, 2009 1:07 pm    Post subject:
Reply with quote

Hi,

This is an interview question, 'am pretty sure Interviewer watned to know that do you know about "ARITH(EXTEND) option" or not..but the answer from Terry is over it..Excellent answer Big B... icon_smile.gif.

Rgards,
Ad
Back to top
View user's profile Send private message
Kmr.deepakcs

New User


Joined: 11 Oct 2013
Posts: 37
Location: India

PostPosted: Sat Nov 02, 2013 11:42 am    Post subject:
Reply with quote

Quote:
If you are restricted to an old compiler where the ARITH(EXTEND) option was not yet available, you could split the 20-digit numbers into "left" and "right" halves, add the right halves together, carry (if necessary) to the left halves, add the left halves, then concatenate the halves back together into your 20-digit number. Of course, since you are limited to 18 digits, you'd need to define that 20-digit number as alphanumeric.

I did not understand this...
can any body explain for me



thanks in advance.

Deepak
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7308

PostPosted: Sat Nov 02, 2013 2:16 pm    Post subject: Reply to: How to add 20 Digits number in Cobol?
Reply with quote

If you have an absurdly old compiler and you want to have a number with 20 significant digits, you can't, as ARITH(EXTEND) which allows for up to 31 digits is not supported.

So you have to split the number into two parts, neither of which exceeds 18 digits.

The likelihood of this situation arising is extremely limited, so I'll leave it at that.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Nov 02, 2013 6:24 pm    Post subject: Reply to: How to add 20 Digits number in Cobol?
Reply with quote

I didn't realise Turkish Lira was being utilised any more.... icon_razz.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts what is meaning of the number in dcl Martylin PL/I & Assembler 2 Thu Mar 09, 2017 7:18 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts GDG version number PANDU1 JCL & VSAM 4 Sat Mar 04, 2017 8:28 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us