diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-24 06:57:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-24 06:57:29 -0700 |
commit | 856c7188075a3e74ac4d9ef4dd665774f193d8d1 (patch) | |
tree | f981d3b4a23a763108d1590444fb56c8c4fae24f /arith.c | |
parent | d510a260dd1755961fe85b6653e9832f49b34201 (diff) | |
download | txr-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.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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)) { |