24 RCSIDH(math_h,
"$Id: ddf80a670a652654abb1bf19c867503ef3a0a911 $")
38 if (num == 0)
return 0;
40 #ifdef HAVE_BUILTIN_CLZLL
41 return (64 - __builtin_clzll(num));
44 while (num >>= 1) ret++;
57 if (num == 0)
return 0;
59 #ifdef HAVE_BUILTIN_CLZLL
60 return __builtin_ctzll(num) + 1;
65 if (num & 0x01)
break;
80 static uint64_t
const pow_of_10[] =
99 100000000000000000ULL,
100 1000000000000000000ULL,
101 10000000000000000000ULL
106 return tmp - (num < pow_of_10[tmp]);
118 #define fr_multiply(_out, _a, _b) !__builtin_mul_overflow(_a, _b, _out)
129 #define fr_add(_out, _a, _b) !__builtin_add_overflow(_a, _b, _out)
140 #define fr_sub(_out, _a, _b) !__builtin_sub_overflow(_a, _b, _out)
144 #define ROUND_UP_POW2(_num, _mul) (((_num) + ((_mul) - 1)) & ~((_mul) - 1))
148 #define ROUND_UP(_num, _mul) (((((_num) + ((_mul) - 1))) / (_mul)) * (_mul))
153 #define ROUND_UP_DIV(_x, _y) (1 + (((_x) - 1) / (_y)))
static uint8_t fr_low_bit_pos(uint64_t num)
Find the lowest order high bit in an unsigned 64 bit integer.
static uint8_t fr_log10(uint64_t num)
Efficient calculation of log10 of a unsigned 64bit integer.
static uint8_t fr_high_bit_pos(uint64_t num)
Find the highest order high bit in an unsigned 64 bit integer.