3 ms·
It works the same way. 7720 in binary is 1111000101000. This is 13 bits. Square root is at most half as long, so first guess is 10000000 in binary, or 128. Sq
by pps43 9y ago
It works the same way.
7720 in binary is 1111000101000. This is 13 bits. Square root is at most half as long, so first guess is 10000000 in binary, or 128.
Square that, realize that it's too high, set the highest bit to 0 and next bit to 1.
Square 1000000 binary or 64, realize that it's too low. Keep the top bit, raise the next bit.
Square 1100000 binary or 96, too high, drop that bit back to zero, raise the next bit.
Square 1010000 binary or 80, too low, raise the next bit.
Square 1011000 binary or 88, too high, drop this bit and raise the next one.
Square 1010100 binary or 84, too low, raise the next bit.
Square 1010110 binary or 86, too low, raise the next bit.
Got 1010111 binary or 87.
- schoen 9y agoIt's awesome to see how binary representation of numbers often leads to a convergence between operations and algorithms conceived in terms of arithmetic and those conceived in terms of logic.