IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

in cobol how we can code for exponent calculations


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 691
Location: Earth

PostPosted: Mon Sep 17, 2007 12:47 pm
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

Moderator Emeritus


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

PostPosted: Mon Sep 17, 2007 12:50 pm
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
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: 2146
Location: At my coffee table

PostPosted: Mon Sep 17, 2007 2:56 pm
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
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

Moderator Emeritus


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

PostPosted: Mon Sep 17, 2007 6:33 pm
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
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: 2146
Location: At my coffee table

PostPosted: Mon Sep 17, 2007 9:11 pm
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: 691
Location: Earth

PostPosted: Tue Sep 18, 2007 2:57 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts run rexx code with jcl CLIST & REXX 15
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Compile rexx code with jcl CLIST & REXX 6
Search our Forums:

Back to Top