Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
gopinathmk

New User

Joined: 17 Nov 2006
Posts: 15

 Posted: Tue Jan 20, 2009 3:42 pm    Post subject: How to add 20 Digits number in Cobol? 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?

dbzTHEdinosauer

Global Moderator

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

 Posted: Tue Jan 20, 2009 4:01 pm    Post subject: you could use the ARITH(EXTEND) option. you can find info in COBOL documentation.
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8567
Location: Dubuque, Iowa, USA

Posted: Tue Jan 20, 2009 5:56 pm    Post subject:

 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.
rajulan

New User

Joined: 11 Jan 2008
Posts: 66
Location: India

 Posted: Tue Jan 27, 2009 12:45 pm    Post subject: 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.
Terry Heinze

JCL Moderator

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

 Posted: Wed Jan 28, 2009 11:51 am    Post subject: 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.
Anuj Dhawan

Senior Member

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

 Posted: Wed Jan 28, 2009 1:07 pm    Post subject: 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... . Rgards, Ad
Kmr.deepakcs

New User

Joined: 11 Oct 2013
Posts: 37
Location: India

Posted: Sat Nov 02, 2013 11:42 am    Post subject:

 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

Deepak
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Sat Nov 02, 2013 2:16 pm    Post subject: Reply to: How to add 20 Digits number in Cobol? 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.
Bill O'Boyle

CICS Moderator

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

 Posted: Sat Nov 02, 2013 6:24 pm    Post subject: Reply to: How to add 20 Digits number in Cobol? I didn't realise Turkish Lira was being utilised any more....
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Missing Negative sign in COBOL jzhardy COBOL Programming 6 Sat Sep 26, 2020 11:32 am COBOL reading from SYSIN jzhardy COBOL Programming 1 Mon Sep 21, 2020 2:37 pm how to read accounting information in... jzhardy COBOL Programming 1 Mon Sep 21, 2020 9:57 am NOT IN clause in COBOL pgm mramvivek COBOL Programming 8 Thu Aug 20, 2020 4:48 am Restart logic by using cursor name in... Twinkle22 Mainframe Interview Questions 1 Wed Jul 29, 2020 11:26 am

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us