mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update sqrt_double.cpp
This commit is contained in:
parent
e9a0234cbe
commit
c8f11deea2
@ -12,8 +12,8 @@ double Sqrt(double x) {
|
|||||||
between 1e-7 and 1e-12.
|
between 1e-7 and 1e-12.
|
||||||
double epsilon = 1e-12;
|
double epsilon = 1e-12;
|
||||||
*/
|
*/
|
||||||
while ( l <= r) {
|
while ( l <= r ) {
|
||||||
double mid = (l + r) / 2;
|
double mid = ( l + r ) / 2;
|
||||||
if ( mid * mid > x ) {
|
if ( mid * mid > x ) {
|
||||||
r = mid;
|
r = mid;
|
||||||
} else {
|
} else {
|
||||||
@ -25,7 +25,6 @@ double Sqrt(double x) {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
double n{};
|
double n{};
|
||||||
std::cin >> n;
|
std::cin >> n;
|
||||||
|
Loading…
Reference in New Issue
Block a user