summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2019-04-25 20:45:58 +0200
committerZenWalker <[email protected]>2019-04-26 15:25:36 +0200
commitb0e4fe242b2b7b0a980d163bbf294f588b084091 (patch)
tree8a23b43e95179e64c39aa5d2c3f966bb30dd359f
parent76f8baf8847ba93dcdc8e1fbfe1bee28cbae74a7 (diff)
downloadmate-calc-b0e4fe242b2b7b0a980d163bbf294f588b084091.tar.bz2
mate-calc-b0e4fe242b2b7b0a980d163bbf294f588b084091.tar.xz
mp: Fix calculate result ln(e^(i*π))
Fixes https://github.com/mate-desktop/mate-calc/issues/100 based in gnome-calculator commit: https://gitlab.gnome.org/GNOME/gnome-calculator/commit/6eb0f2b5e6df456a97a796b35d811376a69679e0
-rw-r--r--src/mp.c8
1 files 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);