Detect division by zero: Difference between revisions

m (fixed broken link)
 
(One intermediate revision by one other user not shown)
Line 1,324:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">val .div = ffn(.x, .y) {
[.x / .y, true]
catch {
if matching(_err'msg -> re/division by 0/, _err["msg"]) {
[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>
6 2 DIV
4 0 <span style="color:blue">DIV</span>
4 0 DIV
{{out}}
<pre>
890

edits