View previous topic :: View next topic
|
Author |
Message |
madhan1582
New User
Joined: 02 Aug 2005 Posts: 3 Location: chennai
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Madhan,
Why not:
if n not = 0
compute ans = m/n
else
display 'cant divide by zero'
end-if |
|
Back to top |
|
|
rssomm
New User
Joined: 05 Jun 2005 Posts: 41 Location: Hyderabad
|
|
|
|
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 |
|
|
bmadhu346
New User
Joined: 05 Jul 2005 Posts: 7 Location: hyderabad
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
sendil
New User
Joined: 30 Jun 2005 Posts: 27
|
|
|
|
if (n > zero)
divide m/n
else
display ' can't divide by zero'
end-if |
|
Back to top |
|
|
|