### Library source code of: sqrt.c Request some inputs to kickstart into understanding, as what is implied by the code as at:

https://opensource.apple.com/source/Libm/Libm-47.1/ppc.subproj/sqrt.c.auto.html

I came across the code, in order to understand the system library code for implementation of: sqrt.c.

As asm (assembly instruction) is used, so for understanding assembly code inlining in C/C++, have started with the book of:
Guide to Assembly Language A Concise Introduction, by James T. Streib.

Though am a computer engineer, and have knowledge of assembly language programming, still face many issues in the code, as:

(i) SqrtTable : cannot understand anything out of it.

Last edited on ```* The algorithm uses Newton�s method to calculate the IEEE-754 correctly * * rounded double square root, starting with 8 bit estimate for: * * g � �x and y � 1/2�x. Using MAF instructions, each iteration refines * * the original approximations g and y with rounding mode set to nearest. * * The final step calculates g with the caller�s rounding restored. This * * in turn guarantees proper IEEE rounding and exceptions. INEXACT is the * * only possible exception raised in this calculation. Initial guesses * * for g and y are determined from argument x via table lookup into the * * array SqrtTable. *```
(some characters are not shown correctly because I don't know what encoding it is)

So I guess the first thing to do is to understand how "Newton's method" works.

Wikipedia wrote:
Newton's method, [...] is a root-finding algorithm which produces successively better approximations to the roots (or zeroes) of a real-valued function.
Wikipedia wrote:
The idea is to start with an initial guess, then to approximate the function by ...

It seems like SqrtTable is used to make that "initial guess".

https://en.wikipedia.org/wiki/Newton%27s_method
Last edited on hmm. Wonder whats in that table. I'd have said shift right half the binary digits (not counting the leading zeros). Eg, 1234567 downshifted by 10 (it has 21 binary digits) is 1205, its root is 1111.blah
Topic archived. No new replies allowed.