I was going through below link enter link description here and going through answers I wanted to calculate time complexity of below suggested code. I played with quite a few values and number of steps are hovering between 23 (even for small values) and say 50 for real big values. How should I go about calculating time complexity for below code - Any pointers?
float val, low, high, mid, oldmid, midsqr;
// Set initial bounds and print heading.
low = 0; high = mid = val; oldmid = -1;
// Keep going until accurate enough.
while (fabs(oldmid - mid) >= 0.00001)
{
oldmid = mid;
// Get midpoint and see if we need lower or higher.
mid = (high + low) / 2;
midsqr = mid * mid;
if (mid * mid > val)
{
high = mid;
printf("- too high\n");
}
else
{
low = mid;
printf("- too low\n");
}
}