Square Root Function
Square Root Function
Returns the square root of an integer number (24 bit). Returns result as a float
float sqrt(unsigned short long x){
// sqrt function returns square root
unsigned short long a,b,c; //24 bit
unsigned char i;
float result;
c=x;
a=63; //seed estimate of root
b=63;
for(i=0;i<8;i++){
a=c/a;
a=(a+b)/2;
b=a;
}
result=(float)a;
return(result+0.001); //Make sure result is never zero
}