diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-03-20 22:11:27 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-03-20 22:11:27 -0700 |
commit | bc665592de673232748e12f189121ee5a8360b93 (patch) | |
tree | 201fc84884ae316c6085103172489d6d6869c5b2 | |
parent | 66c9a8587cb22b031b5234cc5fcc93354574ca9a (diff) | |
download | txr-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-- | ChangeLog | 5 | ||||
-rw-r--r-- | arith.c | 12 |
2 files changed, 11 insertions, 6 deletions
@@ -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. @@ -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; } |