Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I learned one method in high school. I couldn't remember it, and too lazy to try to work it out, but here are some answers.

http://en.wikipedia.org/wiki/Methods_of_computing_square_roo...



I just want to point out one of the links on that page: http://en.wikipedia.org/wiki/Fast_inverse_square_root

Absolutely hilarious and amazingly magical method of algorithmically computing square roots. It right shifts a floating point number to essentially divide the exponent component by 2. Then it uses a weird magic number trick to get the correct result. Awesome random programming trivia.


Note that this is the inverse square root, i.e. 1/sqrt(x) (which can also be written x^(-1/2) ).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: