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

Author Message
ramco_sita

New User

Joined: 25 Jun 2007
Posts: 40
Location: chennai

 Posted: Mon Sep 17, 2007 12:41 pm    Post subject: in cobol how we can code for exponent calculations would like to how to use exponent in compute statements in cobol. when we used ** it gets compiled but the value is not returned to that computed field. anyone who has done this please give your recommendations

agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 686
Location: Earth

 Posted: Mon Sep 17, 2007 12:47 pm    Post subject: Please post sample of your code so that we can help..
dick scherrer

Site Director

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

Posted: Mon Sep 17, 2007 12:50 pm    Post subject:

Hello,

This
 Quote: we used ** it gets compiled but the value is not returned
should work. If you post your variables and the procedure code in question, we can offer suggestions.

Also, post the values used in the calculation and the result when those values are used.
ramco_sita

New User

Joined: 25 Jun 2007
Posts: 40
Location: chennai

 Posted: Mon Sep 17, 2007 2:08 pm    Post subject: The sample code 01 ws-num1 pic 9(9)v9(2). Compute ws-num1 = (1+ 10/100) ** 5
CICS Guy

Senior Member

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

 Posted: Mon Sep 17, 2007 2:56 pm    Post subject: And you are not getting 1.61?
Raghavendra P K

New User

Joined: 24 Aug 2007
Posts: 24
Location: bangalore

 Posted: Mon Sep 17, 2007 5:07 pm    Post subject: Reply to: in cobol how we can code for exponent calculations Hi Sita, the code works fine, here is the code and the output that i have got. 01 WS-NUM1 PIC 9(09)V9(02). 01 WS-NUM2 PIC 9(09).9(02). Procedure division. INITIALIZE WS-NUM1. COMPUTE WS-NUM1 = (1 + 10/100)**5. MOVE WS-NUM1 TO WS-NUM2. DISPLAY 'WS-NUM2 :' WS-NUM2. The Output: WS-NUM2 :000000001.61
dick scherrer

Site Director

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

Posted: Mon Sep 17, 2007 6:33 pm    Post subject:

Hello,

Try this
 Quote: Compute ws-num1 = (1+ 10/100) ** 5
using decimal places in at least ont of these "(1+ 10/100)" operands, not just the answer.
Raghavendra P K

New User

Joined: 24 Aug 2007
Posts: 24
Location: bangalore

 Posted: Mon Sep 17, 2007 9:07 pm    Post subject: Reply to: in cobol how we can code for exponent calculations Hi Dick, I tried to use the decimal values in the fields. but at the end result the decimal values are not coming. its populating the decimal values as zeros. Pelase suggest your inputs.
CICS Guy

Senior Member

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

Posted: Mon Sep 17, 2007 9:11 pm    Post subject: Re: Reply to: in cobol how we can code for exponent calculat

 Raghavendra P K wrote: the code works fine, here is the code and the output that i have got.
 Raghavendra P K wrote: I tried to use the decimal values in the fields. but at the end result the decimal values are not coming. its populating the decimal values as zeros. Pelase suggest your inputs.
Huh?
agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 686
Location: Earth

Posted: Tue Sep 18, 2007 2:57 pm    Post subject: Re: Reply to: in cobol how we can code for exponent calculat

 Raghavendra P K wrote: Hi Dick, I tried to use the decimal values in the fields. but at the end result the decimal values are not coming. its populating the decimal values as zeros. Pelase suggest your inputs.

 Quote: COMPUTE WS-NUM1 = (1.00 + 10 / 100) ** 5.
ramco_sita

New User

Joined: 25 Jun 2007
Posts: 40
Location: chennai

 Posted: Tue Sep 18, 2007 4:36 pm    Post subject: Thanks ! it worked for us in cobol..
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Issue in suppressing leading zeros &a... Vijay_Sirisha COBOL Programming 21 Thu Jun 07, 2018 8:01 pm What will happen if we dont code STOP... Poha Eater COBOL Programming 4 Mon Jun 04, 2018 5:27 pm VBS to VB in COBOL and JCL srajendran2 COBOL Programming 12 Fri Jun 01, 2018 3:04 am JCL to set Return code when Time Out ... vinu78 JCL & VSAM 6 Wed May 30, 2018 11:27 am Rexx code to find greater then symobl... Bharath Vikraman CLIST & REXX 8 Tue May 29, 2018 9:40 am

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