fix infinite loop
This commit is contained in:
parent
4569b3ac46
commit
4edd033ebd
@ -7,7 +7,7 @@ import (
|
||||
|
||||
func Sqrt(x float64) float64 {
|
||||
var p float64
|
||||
for z := 1.0; z != p; z -= (z * z - x) / (2 * z) {
|
||||
for z := 1.0; z != p && math.Abs(z - p) > 0.000000000000001; z -= (z * z - x) / (2 * z) {
|
||||
p = z
|
||||
}
|
||||
return p
|
||||
|
Loading…
Reference in New Issue
Block a user