From 871480933a1c28f8a9fed4c4d34d06c439a7a422 Mon Sep 17 00:00:00 2001 From: Srikant Patnaik Date: Sun, 11 Jan 2015 12:28:04 +0530 Subject: Moved, renamed, and deleted files The original directory structure was scattered and unorganized. Changes are basically to make it look like kernel structure. --- lib/int_sqrt.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/int_sqrt.c (limited to 'lib/int_sqrt.c') diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c new file mode 100644 index 00000000..fc2eeb7c --- /dev/null +++ b/lib/int_sqrt.c @@ -0,0 +1,32 @@ + +#include +#include + +/** + * 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); -- cgit