フィルターのクリア

question concerning rounding of numbers

2 ビュー (過去 30 日間)
Jakob Sievers
Jakob Sievers 2015 年 3 月 26 日
回答済み: Jakob Sievers 2015 年 3 月 27 日
Hi
I am having trouble rounding a number to a fixed number of digits. Can anyone explain the problem I am encountering? (As shown in this figure)

採用された回答

James Tursa
James Tursa 2015 年 3 月 26 日
  1 件のコメント
John D'Errico
John D'Errico 2015 年 3 月 26 日
As has been said, no matter how hard you try, you cannot represent 30.7 exactly as a double precision number. That is a binary representation, and your number is not exactly representable.
In fact, this is true of almost all the numbers you will write in decimal form. The exceptions are integers of a reasonable size, and those numbers that can be written as sums of limited negative powers of 2. So 0.5, and 0.375 will be exactly represented.

サインインしてコメントする。

その他の回答 (2 件)

Luuk van Oosten
Luuk van Oosten 2015 年 3 月 26 日
Yes, I believe your problem is described here

Jakob Sievers
Jakob Sievers 2015 年 3 月 27 日
Thanks for all of your comments. They helped me greatly!

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by