~ chicken-core (chicken-5) dac35041ba1e2577858dd5269190fb6c2e99cca0
commit dac35041ba1e2577858dd5269190fb6c2e99cca0
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Wed Sep 8 08:23:32 2010 -0400
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Wed Sep 8 08:23:32 2010 -0400
yuck1
diff --git a/runtime.c b/runtime.c
index 57378df2..ca328c97 100644
--- a/runtime.c
+++ b/runtime.c
@@ -6282,17 +6282,20 @@ void C_ccall C_divide(C_word c, C_word closure, C_word k, C_word n1, ...)
C_word x, y;
C_word iresult;
double fresult, f;
+ int ff = 0;
C_alloc_flonum;
if(c < 3) C_bad_min_argc(c, 3);
if(n1 & C_FIXNUM_BIT) iresult = n1;
- else if(!C_immediatep(n1) && C_block_header(n1) == C_FLONUM_TAG)
+ else if(!C_immediatep(n1) && C_block_header(n1) == C_FLONUM_TAG) {
fresult = C_flonum_magnitude(n1);
+ ff = 1;
+ }
else barf(C_BAD_ARGUMENT_TYPE_ERROR, "/", n1);
if(c == 3) {
- if(n1 & C_FIXNUM_BIT) {
+ if(!ff) {
if(n1 == C_fix(0)) barf(C_DIVISION_BY_ZERO_ERROR, "/");
else if(n1 == C_fix(1)) C_kontinue(k, C_fix(1));
else C_kontinue_flonum(k, 1 / (double)C_unfix(n1));
@@ -6304,6 +6307,8 @@ void C_ccall C_divide(C_word c, C_word closure, C_word k, C_word n1, ...)
va_start(v, n1);
c -= 3;
+ if(ff) goto flonum_result;
+
while(c--) {
x = va_arg(v, C_word);
diff --git a/tests/ec-tests.scm b/tests/ec-tests.scm
index 87704379..71e9f81e 100644
--- a/tests/ec-tests.scm
+++ b/tests/ec-tests.scm
@@ -650,3 +650,5 @@
(display my-check-wrong)
(newline)
(newline) )
+
+(exit my-check-wrong)
diff --git a/tests/library-tests.scm b/tests/library-tests.scm
index c120f338..cf3f1f37 100644
--- a/tests/library-tests.scm
+++ b/tests/library-tests.scm
@@ -43,6 +43,8 @@
(assert (zero? (+)))
(assert (= 1 (*)))
+(assert (= 2.5 (/ 5 2)))
+
;; number->string conversion
Trap