From 1957af0ef634a426c45d777a7a1000c726c3ff71 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Thu, 25 Apr 2019 20:45:58 +0200 Subject: =?UTF-8?q?mp:=20Fix=20calculate=20result=20ln(e^(i*=CF=80))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/mate-desktop/mate-calc/issues/100 based in gnome-calculator commit: https://gitlab.gnome.org/GNOME/gnome-calculator/commit/6eb0f2b5e6df456a97a796b35d811376a69679e0 --- src/mp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mp.c b/src/mp.c index 3003202..f74f9a9 100644 --- a/src/mp.c +++ b/src/mp.c @@ -1231,7 +1231,7 @@ static void mp_ln_real(const MPNumber *x, MPNumber *z) { int e, k; - float rx, rlx; + double rx, rlx; MPNumber t1, t2; /* LOOP TO GET APPROXIMATE LN(X) USING SINGLE-PRECISION */ @@ -1250,10 +1250,10 @@ mp_ln_real(const MPNumber *x, MPNumber *z) /* REMOVE EXPONENT TO AVOID FLOATING-POINT OVERFLOW */ e = t1.exponent; t1.exponent = 0; - rx = mp_cast_to_float(&t1); + rx = mp_cast_to_double(&t1); t1.exponent = e; - rlx = log(rx) + (float)e * log((float)MP_BASE); - mp_set_from_float(-(double)rlx, &t2); + rlx = log(rx) + e * log(MP_BASE); + mp_set_from_double(-(double)rlx, &t2); /* UPDATE Z AND COMPUTE ACCURATE EXP OF APPROXIMATE LOG */ mp_subtract(z, &t2, z); -- cgit v1.2.1