ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Суббота
22 февраля
1494468 Топик полностью
Andreas (30.01.2025 09:05, просмотров: 160) ответил SciFi на Честно украдено в тырнетах и немного настроено под свои нужды:
С делением неспортивно. Тоже дернуто откуда-то 
unsigned long sqrt_l(unsigned long x)

{

register unsigned long op, res, one;

op = x;

res = 0;

/* "one" starts at the highest power of four <= than the argument. */

one = 1ul << 30; /* second-to-top bit set */

while (one > op) one >>= 2;

while (one != 0)

{

if (op >= res + one)

{

op -= res + one;

res += one << 1; // <-- faster than 2 * one

}

res >>= 1;

one >>= 2;

}

return res;

}