duongame
Android developer
Sunday, February 28, 2016
C++ fast integer square root(sqrt)
int isqrt(int n) {
unsigned int c = 0x8000;
unsigned int g = 0x8000;
for (;;) {
if (g*g > n)
g ^= c;
c >>= 1;
if (c == 0)
return g;
g |= c;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment