summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-20 12:11:38 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-20 12:11:38 -0700
commit270dcc27814f4bd80f625b85e9ff91e7c5a8e8a8 (patch)
treeaf016173b3eb8785928466032f97f772c5f0dc04 /lib.c
parent49b84f76e1036ebeb75b4348d1d0cf7fdf233939 (diff)
downloadtxr-270dcc27814f4bd80f625b85e9ff91e7c5a8e8a8.tar.gz
txr-270dcc27814f4bd80f625b85e9ff91e7c5a8e8a8.tar.bz2
txr-270dcc27814f4bd80f625b85e9ff91e7c5a8e8a8.zip
* arith.c (plus): Optimization: use num_fast when
result is in the fixnum range. Implemented FLNUM cases, except for adding a FLNUM to BGNUM. (minus, mul): Use num_fast when the cnum value is in the fixnum range. (int_flo): New function. * eval.c (eval_init): Register int-flo intrinsic. * lib.c (c_flo): New function. * lib.h (TYPE_SHIFT, TYPE_PAIR): New macros, carried over from the lazy strings branch. (c_flo, int_flo): Declared.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 306d1118..21b87fed 100644
--- a/lib.c
+++ b/lib.c
@@ -1135,6 +1135,12 @@ val flo(double n)
return obj;
}
+double c_flo(val num)
+{
+ type_check(num, FLNUM);
+ return num->fl.n;
+}
+
val fixnump(val num)
{
return (is_num(num)) ? t : nil;