minix/lib/libsys/sqrt_approx.c
Ben Gras 9c01ceb576 introduce sqrt_approx() in -lsys
. use this to avoid -lm dependency in mfs
2011-07-04 02:51:12 +02:00

14 lines
266 B
C

#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;
}