Merge pull request #578 from PX4/fix_mp_prime_strong_lucas_lefridge_compilation
[libtommath.git] / mp_reduce_is_2k_l.c
blob101b4a185d6b87ef99a40959ff6cb1d82b20ae48
1 #include "tommath_private.h"
2 #ifdef MP_REDUCE_IS_2K_L_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* determines if reduce_2k_l can be used */
7 bool mp_reduce_is_2k_l(const mp_int *a)
9 if (mp_iszero(a)) {
10 return false;
11 } else if (a->used == 1) {
12 return true;
13 } else if (a->used > 1) {
14 /* if more than half of the digits are -1 we're sold */
15 int ix, iy;
16 for (iy = ix = 0; ix < a->used; ix++) {
17 if (a->dp[ix] == MP_DIGIT_MAX) {
18 ++iy;
21 return (iy >= (a->used/2));
22 } else {
23 return false;
27 #endif