フィルターのクリア

Why do I get zero?

1 回表示 (過去 30 日間)
StewJo
StewJo 2011 年 6 月 24 日
Running 7.10.0 (R2010a) under Windows 7 on an Intel i5 (Lenovo laptop):
K>> TAhi
TAhi = -8.6578e+009
K>> TAlo
TAlo = -8.6578e+009
K>> TAhi/2.0 - TAlo/2.0
ans = 9.5367e-007
K>> (TAhi+TAlo)/2.0 - TAlo
ans = 0
Why do I get 0 when I should get 9.5367e-007 ? I wouldn't image e-007 is anywhere near machine tolerance.
Any help is appreciated!

採用された回答

Nirmal Gunaseelan
Nirmal Gunaseelan 2011 年 6 月 24 日
The next highest floating point number representable relative to the current number is probably the issue here. Please read further at EPS documentation page.

その他の回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2011 年 6 月 24 日
Maybe you can type in the following command and then do your calculation again to see the difference
format long

David Young
David Young 2011 年 6 月 24 日
(TAhi-TAlo)/TAhi is close to machine precision, and it's this relative size that matters when comparing two almost equal numbers.

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by