Skip to content

Instantly share code, notes, and snippets.

@anirudh-ramesh
Created March 9, 2016 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anirudh-ramesh/f386fe211e01898ab497 to your computer and use it in GitHub Desktop.
Save anirudh-ramesh/f386fe211e01898ab497 to your computer and use it in GitHub Desktop.
// Source: http://supp.iar.com/FilesPublic/SUPPORT/000419/AN-G-002.pdf
unsigned int sqroot(unsigned int x){
unsigned int a,b;
b = x;
a = x = 0x3f;
x = b/x;
a = x = (x+a)>>1;
x = b/x;
a = x = (x+a)>>1;
x = b/x;
x = (x+a)>>1;
return(x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment