I am asking for ways to calculate the square root of any given number in
X = √5
log10X = log10(√5)
log10X = log10(5)/2;
double getlogvalue = log10(5)/2; // in here the get the value of 5 in log10 and divide it from two.
//then get the antilog value for the getlogvalue
double getangilogvalue = pow(10,getlogvalue);
//this will give the square root of any number. and the answer may include for few decimal points. so to print with two decimal point,
NSLog(@"square root of the given number is : %.02f", getantilogvalue);
sqrt function (and other mathematical functions as well) is
available in the standard libraries on all OS X and iOS platforms.
It can be used from (Objective-)C:
#include "math.h" double sqrtFive = sqrt(5.0);
and from Swift:
import Darwin // or Foundation, Cocoa, UIKit, ... let sqrtFive = sqrt(5.0)