1 // SPDX-License-Identifier: GPL-2.0
5 * Based on the shift-and-subtract algorithm for computing integer
6 * square root from Guy L. Steele.
9 #include <linux/kernel.h>
10 #include <linux/export.h>
13 * int_sqrt - rough approximation to sqrt
14 * @x: integer of which to calculate the sqrt
16 * A very rough approximation to the sqrt() function.
18 unsigned long int_sqrt(unsigned long x)
20 unsigned long b, m, y = 0;
25 m = 1UL << (BITS_PER_LONG - 2);
39 EXPORT_SYMBOL(int_sqrt);