summaryrefslogtreecommitdiff
path: root/mpz
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2020-10-29 07:42:04 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2020-10-29 07:42:04 +0100
commitd0397f95bfcdfa2c3952b06295d69c849fc73558 (patch)
treeae0dc3c077bc81d95cf5794dbdf33da1a8cc61c0 /mpz
parent4dc90a38398bcd52993515631e6ffcca9b4f5697 (diff)
downloadgmp-d0397f95bfcdfa2c3952b06295d69c849fc73558.tar.gz
limb_apprsqrt: Slightly faster formula
Diffstat (limited to 'mpz')
-rw-r--r--mpz/bin_uiui.c4
-rw-r--r--mpz/oddfac_1.c4
-rw-r--r--mpz/stronglucas.c4
3 files changed, 6 insertions, 6 deletions
diff --git a/mpz/bin_uiui.c b/mpz/bin_uiui.c
index c62e0ec2e..542d4858e 100644
--- a/mpz/bin_uiui.c
+++ b/mpz/bin_uiui.c
@@ -2,7 +2,7 @@
Contributed to the GNU project by Torbjorn Granlund and Marco Bodrato.
-Copyright 2010-2012, 2015-2018 Free Software Foundation, Inc.
+Copyright 2010-2012, 2015-2018, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -584,7 +584,7 @@ limb_apprsqrt (mp_limb_t x)
ASSERT (x > 2);
count_leading_zeros (s, x);
s = (GMP_LIMB_BITS - s) >> 1;
- return ((CNST_LIMB(1) << s) + (x >> s)) >> 1;
+ return ((CNST_LIMB(1) << (s - 1)) + (x >> 1 >> s));
}
static void
diff --git a/mpz/oddfac_1.c b/mpz/oddfac_1.c
index 904d3501a..e4da05cbf 100644
--- a/mpz/oddfac_1.c
+++ b/mpz/oddfac_1.c
@@ -7,7 +7,7 @@ IT IS ONLY SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES.
IN FACT, IT IS ALMOST GUARANTEED THAT IT WILL CHANGE OR
DISAPPEAR IN A FUTURE GNU MP RELEASE.
-Copyright 2010-2012, 2015-2017 Free Software Foundation, Inc.
+Copyright 2010-2012, 2015-2017, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -132,7 +132,7 @@ limb_apprsqrt (mp_limb_t x)
ASSERT (x > 2);
count_leading_zeros (s, x);
s = (GMP_LIMB_BITS - s) >> 1;
- return ((CNST_LIMB(1) << s) + (x >> s)) >> 1;
+ return ((CNST_LIMB(1) << (s - 1)) + (x >> 1 >> s));
}
#if 0
diff --git a/mpz/stronglucas.c b/mpz/stronglucas.c
index e9a71370e..cf9e7ff40 100644
--- a/mpz/stronglucas.c
+++ b/mpz/stronglucas.c
@@ -5,7 +5,7 @@
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
FUTURE GNU MP RELEASES.
-Copyright 2018 Free Software Foundation, Inc.
+Copyright 2018, 2020 Free Software Foundation, Inc.
Contributed by Marco Bodrato.
@@ -52,7 +52,7 @@ limb_apprsqrt (mp_limb_t x)
ASSERT (x > 2);
count_leading_zeros (s, x);
s = (GMP_LIMB_BITS - s) >> 1;
- return ((CNST_LIMB(1) << s) + (x >> s)) >> 1;
+ return ((CNST_LIMB(1) << (s - 1)) + (x >> 1 >> s));
}
static int