2 * Copyright (C) 2013 Davidlohr Bueso <davidlohr.bueso@hp.com>
4 * Based on the shift-and-subtract algorithm for computing integer
5 * square root from Guy L. Steele.
8 #include <linux/kernel.h>
9 #include <linux/export.h>
12 * int_sqrt - rough approximation to sqrt
13 * @x: integer of which to calculate the sqrt
15 * A very rough approximation to the sqrt() function.
17 unsigned long int_sqrt(unsigned long x
)
19 unsigned long b
, m
, y
= 0;
24 m
= 1UL << (BITS_PER_LONG
- 2);
38 EXPORT_SYMBOL(int_sqrt
);