问题:已知 sqrt (2)约等于 1.414,要求不用数学库,求 sqrt (2)精确到小数点后 10 位。
【方法一】二分查找
double sqrt2( ){
double low = 1.4, high = 1.5;
const double eps = 1e-11;
while (high - low > eps){
double mid = (low + high) / 2;
if
问题:已知 sqrt (2)约等于 1.414,要求不用数学库,求 sqrt (2)精确到小数点后 10 位。
【方法一】二分查找
double sqrt2( ){
double low = 1.4, high = 1.5;
const double eps = 1e-11;
while (high - low > eps){
double mid = (low + high) / 2;
if