public class Solution {

public int sqrt(int x) {

int start = 0;

int finale = x;

while(start<finale)

{

```
float mid = (start+finale)/2;
float diff = (mid*mid)-x;
if(Math.abs(diff)<0.000000000001)
return(int) mid;
else if (diff > 0)
finale = mid-1;
else if(diff<0)
start = (mid+1);
}
return -1;
}
```

}