uint16_t sqrt32(uint32_t a) {
uint32_t rem = 0, root = 0;
for (int i = 32 / 2; i > 0; i--)
{
root <<= 1;
rem = (rem << 2) | (a >> (32 - 2));
a <<= 2;
if (root < rem)
{
rem -= root | 1;
root += 2;
}
}
return root >> 1;
} Post #1664
3.89K
تابعی ساده و بسیار بهینه برای محاسبه رادیکال
- ❤ 19
- 👍 12
- 👏 4