klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit dee6ad811568353c3ff286cf7ce35b850e7cbbe3
parent 4fd4c887b6b86334c41366a833864401ef84fc11
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sun, 15 May 2011 11:50:52 -0300

Added inexact support to abs.

Diffstat:
Msrc/kgnumbers.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/kgnumbers.c b/src/kgnumbers.c @@ -538,6 +538,7 @@ TValue knum_abs(klisp_State *K, TValue n) return (i < 0? i2tv(-i) : n); /* if i == INT32_MIN, fall through */ /* MAYBE: we could cache the bigint INT32_MAX+1 */ + /* else fall through */ } case K_TBIGINT: { /* this is needed for INT32_MIN, can't be in previous @@ -547,11 +548,18 @@ TValue knum_abs(klisp_State *K, TValue n) return kbigint_abs(K, n); } case K_TBIGRAT: { - kensure_bigrat(n); return kbigrat_abs(K, n); } + case K_TDOUBLE: { + return ktag_double(fabs(dvalue(n))); + } case K_TEINF: return KEPINF; + case K_TIINF: + return KIPINF; + case K_TRWNPV: + /* ASK John: is the error here okay */ + arith_return(K, KRWNPV); default: /* shouldn't happen */ klispE_throw_simple(K, "unsupported type");