summaryrefslogtreecommitdiffstats
path: root/arith.c
diff options
context:
space:
mode:
Diffstat (limited to 'arith.c')
-rw-r--r--arith.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/arith.c b/arith.c
index 14d3d0e2..7051ddb8 100644
--- a/arith.c
+++ b/arith.c
@@ -946,13 +946,20 @@ static val to_float(val func, val num)
val divi(val anum, val bnum)
{
- double a = c_flo(to_float(lit("divi"), anum));
- double b = c_flo(to_float(lit("divi"), bnum));
+ if (missingp(bnum)) {
+ double b = c_flo(to_float(lit("/"), anum));
+ if (b == 0.0)
+ uw_throw(numeric_error_s, lit("/: division by zero"));
+ return flo(1.0 / b);
+ } else {
+ double a = c_flo(to_float(lit("/"), anum));
+ double b = c_flo(to_float(lit("/"), bnum));
- if (b == 0.0)
- uw_throw(numeric_error_s, lit("divi: division by zero"));
+ if (b == 0.0)
+ uw_throw(numeric_error_s, lit("/: division by zero"));
- return flo(a / b);
+ return flo(a / b);
+ }
}
val zerop(val num)