Binary search on reals uses precision threshold or fixed iterations.
Example:
function sqrt(x):
lo = 0, hi = max(1, x)
for i from 1 to 100:
mid = (lo + hi) / 2
if mid * mid < x: lo = mid
else: hi = mid
return lo
Why iterations? Each halves error. After : error , negligible.
Alternative: while hi - lo > 1e-9. Careful with floating-point comparison.