Revision 43598875b35fdd3f699954078b7df24b5647a27a authored by Ben Skeggs on 22 November 2012, 03:27:37 UTC, committed by Ben Skeggs on 28 November 2012, 23:58:04 UTC
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent e5e454f
int_sqrt.c
#include <linux/kernel.h>
#include <linux/export.h>
/**
* int_sqrt - rough approximation to sqrt
* @x: integer of which to calculate the sqrt
*
* A very rough approximation to the sqrt() function.
*/
unsigned long int_sqrt(unsigned long x)
{
unsigned long op, res, one;
op = x;
res = 0;
one = 1UL << (BITS_PER_LONG - 2);
while (one > op)
one >>= 2;
while (one != 0) {
if (op >= res + one) {
op = op - (res + one);
res = res + 2 * one;
}
res /= 2;
one /= 4;
}
return res;
}
EXPORT_SYMBOL(int_sqrt);
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...