Detect division by zero: Difference between revisions
→{{header|langur}}
m (fixed broken link) |
Langurmonkey (talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 1,324:
=={{header|langur}}==
<syntaxhighlight lang="langur">val .div =
[.x / .y, true]
catch {
if
[0, false]
} else {
Line 2,097:
=={{header|RPL}}==
RPL provides targeted error detection and handling. In case of a division by zero, rather than displaying an error message, the program delivers the attempted arithmetic operation as an expression to be further processed.
≪ '''IFERR''' / '''THEN'''
SWAP "'" SWAP →STR + "/" + SWAP →STR + STR→
'''END
≫ '<span style="color:blue">DIV</span>' STO
6 2 <span style="color:blue">DIV</span>
4 0 <span style="color:blue">DIV</span>
{{out}}
<pre>
|