Viewing a single comment thread. View all comments

Psyese t1_j24evge wrote

So how much memory does the calculator need to store all the squares in a table?

1

mfb- t1_j24l46t wrote

As mentioned, a calculator will typically do it a bit differently. Usually numbers are stored in floating point format. 40 wouldn't be stored as "40", but as 1.01*2^5 where 1.01 is a binary number. 1.01*2^5 = 101000 in binary which is 32+8=40 in decimal.

The square root of a product of two numbers is the product of square roots: sqrt(a*b) = sqrt(a)*sqrt(b). To calculate the square root of 2^(n), we just need to divide n by 2: sqrt(2^(5)) = 2^(5/2) = 2^2 * sqrt(2). The calculator knows sqrt(2), so it only needs to calculate the square root of 1.01 (in binary), or more generally any number between 1.0 and 1.111... = 10 (i.e. 2 in decimal). The smallest and largest number only differ by a factor 2. You can make a few entries in a table to use as starting values, or just use the same value for all cases - it won't be that far off anyway. Do a few steps of the method I showed, multiply the result by the square root of 2 if needed (if the original exponent was odd), combine it with the integer powers of 2 (here 2^(2)) and you get the square root.

15

RSA0 t1_j24rosr wrote

You don't need a table of squares. This method works, even if you don't start with a square. You just need to start as close as possible to the square root.

Even some crude approximation, like "closest power of 10", is enough for the initial value.

3