Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to find if the decimal part contains a non zero value

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

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Tue Mar 17, 2009 8:48 pm    Post subject: How to find if the decimal part contains a non zero value
Reply with quote

Hi,

My requirement is to find out whether the decimal part contains a non zero value. I am using the below logic to find this and it works fine.
But I am certain, there must be a better way to do this.

Example:

Code:
 field1 pic 9(2)v9(2)
 field2 pic 9(2)v9(2)

 Compute field1 Rounded = field2
 If field1 not = field2
    some process
 End-if
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 17, 2009 9:11 pm    Post subject:
Reply with quote

Just redefine field1 as
Code:
03 field1 pic 9(2)v9(2)
 03 field2 redefines field1.
      04      pic xx.
      04 field2-dec pic 99.

if field2-dec Not = 0
    some process
end-if.


This avoids the extra processing for the compute.
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Tue Mar 17, 2009 9:23 pm    Post subject:
Reply with quote

Craq,

Thanks a lot!!!
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: Tue Mar 17, 2009 9:46 pm    Post subject:
Reply with quote

Or:
Code:
field1 pic 9(2)v9(2)

if field1(3:2) Not = Zeros
    some process
end-if.
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 How can I convert charactor to fixed ... liying DFSORT/ICETOOL 4 Tue May 22, 2018 3:35 pm
No new posts Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 5 Fri Apr 20, 2018 4:17 pm
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm
No new posts Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us