Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1 +1,2 @@
|
|||
Write a function to detect a divide by zero error without checking if the denominator is zero.
|
||||
Write a function to detect a divide by zero error
|
||||
without checking if the denominator is zero.
|
||||
|
|
|
|||
3
Task/Detect-division-by-zero/00META.yaml
Normal file
3
Task/Detect-division-by-zero/00META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(condition-case nil
|
||||
(/ 1 0)
|
||||
(arith-error
|
||||
(message "Divide by zero (either integer or float)")))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
iferr(1/0,
|
||||
err,
|
||||
print("division by 0"); print("or other non-invertible divisor"),
|
||||
errname(err) == "e_INV");
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
/* A function is not required to detect division by zero. */
|
||||
/* The following statement is executed anywhere prior to */
|
||||
/* executing the statement containing the division by zero. */
|
||||
Proc DivideDZ(a,b) Returns(Float Bin(33));
|
||||
Dcl (a,b,c) Float Bin(33);
|
||||
On ZeroDivide GoTo MyError;
|
||||
c=a/b;
|
||||
Return(c);
|
||||
MyError:
|
||||
Put Skip List('Divide by Zero Detected!');
|
||||
End DivideDZ;
|
||||
|
||||
on zerodivide snap go to trap_zerodivide;
|
||||
xx=DivideDZ(1,0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue