summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_s_mp_log_2expt.c
blob: e87ff358b3204c27a0b43b0fc12a407c7180978b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include "tommath_private.h"
#ifdef BN_S_MP_LOG_2EXPT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */

int s_mp_log_2expt(const mp_int *a, mp_digit base)
{
   int y;
   for (y = 0; (base & 1) == 0; y++, base >>= 1) {}
   return (mp_count_bits(a) - 1) / y;
}
#endif