summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormbkma <[email protected]>2021-02-13 11:02:06 +0100
committerraveit65 <[email protected]>2021-03-18 22:34:32 +0100
commit2e4b911386a88cfb3d34e8578d0f728f684d13e5 (patch)
tree395017348c0360529a9dfd0527c01346222b8553 /src
parent5fac0d4fec1d22bb9124bf5f219148c66d368e09 (diff)
downloadmate-calc-2e4b911386a88cfb3d34e8578d0f728f684d13e5.tar.bz2
mate-calc-2e4b911386a88cfb3d34e8578d0f728f684d13e5.tar.xz
mp.c: mp_reciprocal: fix when calling it with same arguments.
Diffstat (limited to 'src')
-rw-r--r--src/mp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mp.c b/src/mp.c
index 1f3965e..40aacdc 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -403,8 +403,11 @@ mp_invert_sign(const MPNumber *x, MPNumber *z)
void
mp_reciprocal(const MPNumber *x, MPNumber *z)
{
- mpc_set_si(z->num, 1, MPC_RNDNN);
- mpc_fr_div(z->num, mpc_realref(z->num), x->num, MPC_RNDNN);
+ mpc_t temp;
+ mpc_init2(temp, PRECISION);
+ mpc_set_ui(temp, 1, MPC_RNDNN);
+ mpc_fr_div(z->num, mpc_realref(temp), x->num, MPC_RNDNN);
+ mpc_clear(temp);
}
void