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
 

 

in cobol how we can code for exponent calculations

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Mon Sep 17, 2007 12:41 pm    Post subject: in cobol how we can code for exponent calculations
Reply with quote

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
Back to top
View user's profile Send private message

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Mon Sep 17, 2007 12:47 pm    Post subject:
Reply with quote

Please post sample of your code so that we can help..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Sep 17, 2007 12:50 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Mon Sep 17, 2007 2:08 pm    Post subject:
Reply with quote

The sample code

01 ws-num1 pic 9(9)v9(2).

Compute ws-num1 = (1+ 10/100) ** 5
Back to top
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Mon Sep 17, 2007 2:56 pm    Post subject:
Reply with quote

And you are not getting 1.61?
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Mon Sep 17, 2007 5:07 pm    Post subject: Reply to: in cobol how we can code for exponent calculations
Reply with quote

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
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Sep 17, 2007 6:33 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Mon Sep 17, 2007 9:07 pm    Post subject: Reply to: in cobol how we can code for exponent calculations
Reply with quote

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.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


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

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

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?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

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

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.


Please try following-
Quote:
COMPUTE WS-NUM1 = (1.00 + 10 / 100) ** 5.
Back to top
View user's profile Send private message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Tue Sep 18, 2007 4:36 pm    Post subject:
Reply with quote

Thanks ! it worked for us in cobol..
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 -> COBOL Programming 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. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm


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