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 | aa002f36951ceab4011640d75b67ec775cb62850 (patch) | |
tree | f981d3b4a23a763108d1590444fb56c8c4fae24f /arith.c | |
parent | 72741e11b073a4f4f83ebd70e0bf5553613fd99b (diff) | |
download | txr-aa002f36951ceab4011640d75b67ec775cb62850.tar.gz txr-aa002f36951ceab4011640d75b67ec775cb62850.tar.bz2 txr-aa002f36951ceab4011640d75b67ec775cb62850.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)) { |