summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-22 16:53:29 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-22 16:53:29 +0000
commit9c93bc20cc68e50461bb086f24f335de9dcc5135 (patch)
treeff860c161b890feaa16846ce00fe6c55c2929db5 /functions.c
parent071bef0ccfca9137eb3c814cbc9552f02e6f1b4d (diff)
Implement ⎕DIV for allowing division by zero to result in 0 if needed
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/functions.c b/functions.c
index 870ee17..2e0bfa2 100644
--- a/functions.c
+++ b/functions.c
@@ -680,8 +680,12 @@ SCALAR_FUNCTION_2(fnTimes, 0, left->type,
SCALAR_FUNCTION_2(fnDivide, 1, left->type,
case AtypeFloat:
- if(right->floatdata[i] == 0)
- throwerror(nil, EDomain);
+ if(right->floatdata[i] == 0){
+ if(currentsymtab->div)
+ res->floatdata[i] = 0;
+ else
+ throwerror(nil, EDomain);
+ }
else
res->floatdata[i] /= right->floatdata[i];
break;