algorithm - Computing the square root of 1000+ bit word in C -


imagine have e.g. 1000 bit word in our memory. i'm wondering if there way calcuate square root of (not accurate, lets without floating point part). or we've got memory location , later specified various size.

i assume our large number 1 array (most significant bits @ beginning?). square root more or less half of original number. when trying use digit-by-digit algorithm there point when usnigned long long not enough remember partial result (subtraction 01 extended number). how solve it? getting single digit of large number? bitmask?

while thinking pseudocode stucked @ questions. ideas?

how hand? how divide 1000 digit number 500 digit hand? (just think method, quite time consuming). square root, method similar division "guess" first digit, second digit , on , subtract things. it's square root, subtract different things (but not that different, calculating square root can done in way similar division except each digit added, divisor changes).

i wouldn't want tell how it, because spoils whole fun of discovering yourself.

the trick is: instead of thinking square root of x, think finding number y such y*y = x. , improve y, recalculate x - y*y minimum effort.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -