summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-20 22:11:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-20 22:11:27 -0700
commitbc665592de673232748e12f189121ee5a8360b93 (patch)
tree201fc84884ae316c6085103172489d6d6869c5b2
parent66c9a8587cb22b031b5234cc5fcc93354574ca9a (diff)
downloadtxr-bc665592de673232748e12f189121ee5a8360b93.tar.gz
txr-bc665592de673232748e12f189121ee5a8360b93.tar.bz2
txr-bc665592de673232748e12f189121ee5a8360b93.zip
* arith.c (plus): Completed implementation of bignum-float
and float-bignum cases.
-rw-r--r--ChangeLog5
-rw-r--r--arith.c12
2 files changed, 11 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f4f4efde..2c70a4e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2012-03-20 Kaz Kylheku <kaz@kylheku.com>
+ * arith.c (plus): Completed implementation of bignum-float
+ and float-bignum cases.
+
+2012-03-20 Kaz Kylheku <kaz@kylheku.com>
+
* stream.c (vformat): Use larger num_buf buffer so we don't
overrun. IEEE double floats can go to e+-308.
diff --git a/arith.c b/arith.c
index 769da0d0..09529b43 100644
--- a/arith.c
+++ b/arith.c
@@ -259,10 +259,8 @@ int highest_bit(int_ptr_t n)
val plus(val anum, val bnum)
{
- int tag_a = tag(anum);
- int tag_b = tag(bnum);
-
- switch (TAG_PAIR(tag_a, tag_b)) {
+tail:
+ switch (TAG_PAIR(tag(anum), tag(bnum))) {
case TAG_PAIR(TAG_NUM, TAG_NUM):
{
cnum a = c_num(anum);
@@ -352,9 +350,11 @@ val plus(val anum, val bnum)
return flo(c_flo(anum) + c_flo(bnum));
}
case TYPE_PAIR(BGNUM, FLNUM):
+ anum = flo_int(anum);
+ goto tail;
case TYPE_PAIR(FLNUM, BGNUM):
- uw_throwf(error_s, lit("plus: unimplemented bignum float combo ~s ~s"),
- anum, bnum, nao);
+ bnum = flo_int(bnum);
+ goto tail;
default:
break;
}