Submitted by Mikinak77 t3_zy5yuj in explainlikeimfive
mfb- t1_j24l46t wrote
Reply to comment by Psyese in ELI5 How do calculators get the square root of random numbers? by Mikinak77
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.
[deleted] t1_j24pj5b wrote
[deleted]
Viewing a single comment thread. View all comments