search for: find_mod_mul_inverse

Displaying 1 result from an estimated 1 matches for "find_mod_mul_inverse".

2019 Feb 20
2
proposal for optimization method
...nt32 x) { return x%d==r; } if we know d and r at compile time, and d is an odd integer, we can use modular multiplicative inverse to bypass the division operation. I wrote the following code to calculate the M.M.I of a number over 2^b. I give anyone the permission to use it (unlicensed). uint64_t find_mod_mul_inverse(uint64_t x, uint64_t bits) { if (bits > 64 || ((x&1)==0)) return 0;// invalid parameters uint64_t mask; if (bits == 64) mask = -1; else { mask = 1; mask<<=bits; mask-...