From 856c7188075a3e74ac4d9ef4dd665774f193d8d1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 24 Sep 2016 06:57:29 -0700 Subject: 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. --- arith.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'arith.c') 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)) { -- cgit v1.2.3