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
 

 

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 Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


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