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

How to find if the decimal part contains a non zero value


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 2146
Location: At my coffee table

PostPosted: Tue Mar 17, 2009 9:46 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
Search our Forums:

Back to Top