We probably all know that sqrt() returns the square root of its argument,I found its prototype within math.h header but does anyone knows where is the body(or implementation) of this functions
and if not exist than how it works(or how it does its job)
so how can I know the body contents of this function?
I do my own functions that do same as c/c++ library function like(strcmp,max,..)
but I wich to get the original implementation of these functions
so is there anyway to seek that?
If you are looking for an algorithm it isn't difficult to find the square root using an iterative process. Repeat this as required: estimate = ((n/estimate) + estimate) * 0.5;
It is necessary to (a) choose an initial value for estimate and (b) decide when to terminate.
Even though it's not open source licensed, most of the source for the Microsoft CRT is provided with Visual Studio. But the source for the maths functions isn't provided; grep only finds sqrt in headers and in four libraries, all called tran.lib, which I have a suspicion come from hand-written assembly code rather than C++.
(This is for a paid for version of Visual Studio 2008; I only have Express editions of 2010 and 2012, and the libraries aren't included with them.)
But note that when you use Visual C++'s default compile options for a release build, sqrt doesn't come from any library, dynamic or static. It's one of a number of functions which is provided as an intrinsic (or built-in) function. That is, the compiler know what sequence of assembly code is needed for the function and just pastes it directly into your executable.