summaryrefslogtreecommitdiffstats
path: root/arith.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-24 06:57:29 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-24 06:57:29 -0700
commit856c7188075a3e74ac4d9ef4dd665774f193d8d1 (patch)
treef981d3b4a23a763108d1590444fb56c8c4fae24f /arith.c
parentd510a260dd1755961fe85b6653e9832f49b34201 (diff)
downloadtxr-856c7188075a3e74ac4d9ef4dd665774f193d8d1.tar.gz
txr-856c7188075a3e74ac4d9ef4dd665774f193d8d1.tar.bz2
txr-856c7188075a3e74ac4d9ef4dd665774f193d8d1.zip
New functions: tofloatz and tointz.
* arith.c (tofloatz, tointz): New functions. * arith.h (tofloatz, tointz): Declared. * eval.c (eval_init): Register tofloatz and tointz intrinsics. * txr.1: Documented new functions.
Diffstat (limited to 'arith.c')
-rw-r--r--arith.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arith.c b/arith.c
index 5eb022ec..df8dbb5d 100644
--- a/arith.c
+++ b/arith.c
@@ -2297,6 +2297,22 @@ val toint(val obj, val base)
}
}
+val tofloatz(val obj)
+{
+ uses_or2;
+ if (nilp(obj))
+ return flo(0.0);
+ return or2(tofloat(obj), flo(0.0));
+}
+
+val tointz(val obj, val base)
+{
+ uses_or2;
+ if (nilp(obj))
+ return zero;
+ return or2(toint(obj, base), zero);
+}
+
val width(val obj)
{
switch (tag(obj)) {