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
 

 

to check divide by zero codition?

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

New User


Joined: 02 Aug 2005
Posts: 3
Location: chennai

PostPosted: Wed Aug 10, 2005 7:57 pm    Post subject: to check divide by zero codition?
Reply with quote

is there any statement in cobol to check divide by zero condition as in PLI?


eg compute ans = m/n
where m is 20 and n is 0
what error it will give?


pls reply me?
Back to top
View user's profile Send private message

mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Aug 11, 2005 3:51 am    Post subject:
Reply with quote

Hi Madhan,

Why not:

if n not = 0
compute ans = m/n
else
display 'cant divide by zero'
end-if
Back to top
View user's profile Send private message
rssomm

New User


Joined: 05 Jun 2005
Posts: 41
Location: Hyderabad

PostPosted: Thu Aug 11, 2005 9:22 am    Post subject:
Reply with quote

Hi madhan1582,


Use ON SIZE ERROR condition.

For example
Divide A by B giving C On Size error display 'Division by zero'.

If B is Zero the message will be displayed.

Regards
Madhu
Back to top
View user's profile Send private message
bmadhu346

New User


Joined: 05 Jul 2005
Posts: 7
Location: hyderabad

PostPosted: Fri Aug 19, 2005 7:00 pm    Post subject:
Reply with quote

hi friend
ifu divide numeric by zero u will get a soc c abend so while coding follow on size error imperative satement in the coding


regards
madhu
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Aug 20, 2005 11:30 pm    Post subject:
Reply with quote

Hi Madhu,

The only problem w/your solution is that a "legitimate" size error (i.e. a result that exceeds the size of the receiving data) area will produce the same msg. That can cause confusion and delays in the prob res process.
Back to top
View user's profile Send private message
sendil

New User


Joined: 30 Jun 2005
Posts: 27

PostPosted: Thu Aug 25, 2005 12:01 pm    Post subject:
Reply with quote

if (n > zero)
divide m/n
else
display ' can't divide by zero'
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 Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Syntax to check the first 4 digits of... kshirabdhi DFSORT/ICETOOL 10 Tue May 03, 2016 12:21 pm
No new posts Check special resource availability w... pinimo JCL & VSAM 8 Fri Apr 15, 2016 8:18 pm


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