diff options
author | Pablo Barciela <[email protected]> | 2019-04-25 20:45:58 +0200 |
---|---|---|
committer | Pablo Barciela <[email protected]> | 2019-04-26 15:26:29 +0200 |
commit | 1957af0ef634a426c45d777a7a1000c726c3ff71 (patch) | |
tree | 8a6d6ecd46ea878e69c47e006f83f035185cc985 /src/mp.c | |
parent | de580bfc5d8dfa5f734d8d152c9940a110ee65a8 (diff) | |
download | mate-calc-1957af0ef634a426c45d777a7a1000c726c3ff71.tar.bz2 mate-calc-1957af0ef634a426c45d777a7a1000c726c3ff71.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
Diffstat (limited to 'src/mp.c')
-rw-r--r-- | src/mp.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); |