We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
69. Sqrt(x)
如何求平方根?二分,但如果带精度呢?用左右边界去逼近。
某du外包题。唉,我没考虑到精度,感觉还是不善于思考。
public double mySqrt(double val, double e) { double l = 0, r = val; while (r - l > e) { double m = (l + r) / 2.0; if (m * m < val) { l = m; } else if (m * m > val) { r = m; } else { return m; } } return (l + r) / 2.0; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
69. Sqrt(x)
69. Sqrt(x)
如何求平方根?二分,但如果带精度呢?用左右边界去逼近。
某du外包题。唉,我没考虑到精度,感觉还是不善于思考。
The text was updated successfully, but these errors were encountered: