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
 

 

Expecting Decimal point in COMPUTE verb

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

New User


Joined: 15 Aug 2006
Posts: 44
Location: Virginia, USA

PostPosted: Sat Feb 24, 2007 1:45 am    Post subject: Expecting Decimal point in COMPUTE verb
Reply with quote

Hi guys,
In a program I am using
01 WS-VALUE1 PIC9(10) VALUE 2336440320
01 WS-COMPUTED-VALUE PIC9(02)V9(03)

Compute WS-COMPUTED-VALUE ROUNDED = (WS-VALUE1/3999999999)*100

The result i am getting is 5841.

I am expecting is 58.41

Could you please provide me some solution for this

Thanks
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Sat Feb 24, 2007 2:06 am    Post subject: Re: Compute Verb
Reply with quote

My result using your code is 58.410.
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: Sat Feb 24, 2007 2:12 am    Post subject:
Reply with quote

Hello,

I'd recomend placing periods at the end of your statements.

In this
Code:
01 WS-COMPUTED-VALUE PIC9(02)V9(03)

field, there is no decimal point defined - what you have is an implied decimal, not an explicit one. If you wan to see the '.', you must include it in the definition.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Feb 24, 2007 2:28 am    Post subject:
Reply with quote

How do you know you are getting 5841 rather than 58.41?
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: Sat Feb 24, 2007 2:57 am    Post subject:
Reply with quote

Hello again,

With the implied and then the explicit decimal point
Code:

01  WS-VALUE1 PIC 9(10) VALUE 2336440320.
01  WS-COMPUTED-VALUE PIC 9(02)V9(03).   
01  WS-DOT-VALUE      PIC 9(02).9(03).   

       COMPUTE WS-COMPUTED-VALUE ROUNDED =       
               (WS-VALUE1/3999999999)*100.       
       DISPLAY WS-COMPUTED-VALUE.                 
       MOVE WS-COMPUTED-VALUE TO WS-DOT-VALUE.   
       DISPLAY WS-DOT-VALUE.                     

you get
Code:

58410   
58.410 
Back to top
View user's profile Send private message
alluri12

New User


Joined: 15 Aug 2006
Posts: 44
Location: Virginia, USA

PostPosted: Sat Feb 24, 2007 3:13 am    Post subject: Re: Compute Verb
Reply with quote

Thanks guys for replying so fast. It helps.
Dick, you explaination was crystal clear... thankyou
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: Sat Feb 24, 2007 3:23 am    Post subject:
Reply with quote

You're welcome icon_smile.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Feb 24, 2007 4:53 am    Post subject:
Reply with quote

dick scherrer wrote:
With the implied and then the explicit decimal point
Dang, ya beat me to it...I was heading there, I was just fishing for confirmation..... icon_biggrin.gif

Good call! icon_wink.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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Online Assembler Program Starting point Aditya.Srivastava PL/I & Assembler 4 Fri Jul 08, 2016 6:48 pm
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts conversion from char to packed decimal Musab Ahmed DFSORT/ICETOOL 7 Fri Apr 08, 2016 1:12 pm


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