s**i 发帖数: 381 | 1 Hi,
it is well known that we should try to avoid the subtration of two nearly equal
numbers due to the cancellation error.
Is there any smart way to rewrite 1-a/b when a and b are close?
Thanks. | r****y 发帖数: 1437 | 2
double precision a, b
double precision c
c = 1.0d0/b
1.0d0 - a * c
equal
【在 s**i 的大作中提到】 : Hi, : it is well known that we should try to avoid the subtration of two nearly equal : numbers due to the cancellation error. : Is there any smart way to rewrite 1-a/b when a and b are close? : Thanks.
| i*******n 发帖数: 166 | 3 (b-a)/b
【在 s**i 的大作中提到】 : Hi, : it is well known that we should try to avoid the subtration of two nearly equal : numbers due to the cancellation error. : Is there any smart way to rewrite 1-a/b when a and b are close? : Thanks.
|
|