minix3/lib/libsys/sqrt_approx.c

15 lines
266 B
C
Raw Normal View History

2020-02-21 00:59:27 +05:30
#include <minix/sysutil.h>
u32_t sqrt_approx(u32_t in)
{
int b, v = 0;
for(b = (sizeof(in)*8)/2-1; b >= 0; b--) {
u32_t n = v | (1UL << b);
if(n*n <= in)
v = n;
}
return v;
}