From 7c050399fa8f4e782e59ce878c69033d54bcf2b7 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Tue, 8 Dec 2009 23:26:16 +0100 Subject: [PATCH] Fixed LOG of negative bignums and of complex numbers with equal positive and negative parts. --- src/c/num_sfun.d | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/c/num_sfun.d b/src/c/num_sfun.d index d56538784..5b8f94bda 100644 --- a/src/c/num_sfun.d +++ b/src/c/num_sfun.d @@ -235,7 +235,6 @@ ecl_log1_complex(cl_object r, cl_object i) */ a = ecl_times(a, a); a = ecl_divide(ecl_log1(ecl_plus(a, a)), MAKE_FIXNUM(2)); - p = MAKE_FIXNUM(0); goto OUTPUT; } /* For the real part of the output we use the formula @@ -244,8 +243,8 @@ ecl_log1_complex(cl_object r, cl_object i) a = ecl_divide(a, p); a = ecl_plus(ecl_divide(ecl_log1p(ecl_times(a,a)), MAKE_FIXNUM(2)), ecl_log1(p)); - p = ecl_atan2(i, r); OUTPUT: + p = ecl_atan2(i, r); return ecl_make_complex(a, p); } @@ -264,11 +263,14 @@ ecl_log1(cl_object x) break; } case t_bignum: { - cl_fixnum l = ecl_integer_length(x) - 1; - cl_object r = ecl_make_ratio(x, ecl_ash(MAKE_FIXNUM(1), l)); - float d = logf(number_to_float(r)) + l * logf(2.0); - if (d < 0) goto COMPLEX; - output = ecl_make_singlefloat(d); + if (ecl_minusp(x)) { + goto COMPLEX; + } else { + cl_fixnum l = ecl_integer_length(x) - 1; + cl_object r = ecl_make_ratio(x, ecl_ash(MAKE_FIXNUM(1), l)); + float d = logf(number_to_float(r)) + l * logf(2.0); + output = ecl_make_singlefloat(d); + } break; } #ifdef ECL_SHORT_FLOAT