Binary Search in Monotonic Spaces

In float square_root function why there is

ans = ans - inc ;

and what is the meaning of overshot the value used in comments written above this code ??

@jatinhazrati you have to decrease the inc from ans because while loop is broken AFTER the condition is false, meaning ans^2 has just exceeded the value of square. so we need to take one step backwards.
this is the meaning of “overshot” the value, that we have “exceeded” the answer.

1 Like

@jatinhazrati please mark the doubt as resolved if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.