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: 6967
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: 8057
Location: East Dubuque, Illinois, USA

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: 7315

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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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