mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: sqrt_double hangs on x < 1 (#760)
This commit is contained in:
parent
d079d1fda4
commit
51eb5beab5
@ -6,6 +6,9 @@ number in O(logn) time,
|
|||||||
with precision fixed */
|
with precision fixed */
|
||||||
|
|
||||||
double Sqrt(double x) {
|
double Sqrt(double x) {
|
||||||
|
if ( x > 0 && x < 1 ) {
|
||||||
|
return 1/Sqrt(1/x);
|
||||||
|
}
|
||||||
double l = 0, r = x;
|
double l = 0, r = x;
|
||||||
/* Epsilon is the precision.
|
/* Epsilon is the precision.
|
||||||
A great precision is
|
A great precision is
|
||||||
|
Loading…
Reference in New Issue
Block a user