summaryrefslogtreecommitdiffstats
path: root/buf.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-11-07 06:05:13 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-11-07 06:05:13 -0800
commit6fdad9e0389cb51b5822fda2920f510cb9a8881a (patch)
tree8b0053b4d4d810f13f3f5677632cb0b0caed9170 /buf.c
parentf94626c565cbe25773d680c6adf518b8570b8170 (diff)
downloadtxr-6fdad9e0389cb51b5822fda2920f510cb9a8881a.tar.gz
txr-6fdad9e0389cb51b5822fda2920f510cb9a8881a.tar.bz2
txr-6fdad9e0389cb51b5822fda2920f510cb9a8881a.zip
math: improve error diagnosis.
More streamlined code, better identification of functions. * arith.c (not_number, not_integer, invalid_ops, invalid_op, divzero): New static functions. (num_to_buffer, bugnum_len, plus, minus, neg, abso, signum, mul, trunc1, mod, floordiv, round1, roundiv, divi, zerop, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt, exptmod, floorf, ceili, sine, cosi, tang, asine, acosi, atang, loga, logten, logtwo, expo, sqroot, int_flo, flo_int, cum_norm_dist, inv_cum_norm): Establish function's Lisp name as self variable. Use new static functions for reporting common errors. Pass function name to new argument of c_flo function. * buf.c (buf_put_float, buf_put_double): Pass function's Lisp name to c_flo function. * ffi.c (ffi_float_put, ffi_double_put): Likewise. * lib.c (c_flo): Takes new argument, name of calling function. * lib.h (c_flo): Declaration updated. * stream.c (formatv): Pass function name to c_flo.
Diffstat (limited to 'buf.c')
-rw-r--r--buf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/buf.c b/buf.c
index bd5d1bdf..18f2a157 100644
--- a/buf.c
+++ b/buf.c
@@ -399,7 +399,7 @@ val buf_put_float(val buf, val pos, val num)
{
val self = lit("buf-put-float");
double n;
- double f = c_flo(num);
+ double f = c_flo(num, self);
if (f > FLT_MAX || f < FLT_MIN)
uw_throwf(error_s, lit("~a: ~s is out of float range"), self, num, nao);
@@ -412,7 +412,7 @@ val buf_put_float(val buf, val pos, val num)
val buf_put_double(val buf, val pos, val num)
{
val self = lit("buf-put-double");
- double n = c_flo(num);
+ double n = c_flo(num, self);
buf_put_bytes(buf, pos, coerce(mem_t *, &n), sizeof n, self);
return num;
}