利用Matlab计算小数除法时,计算结果出现问题

8 ビュー (過去 30 日間)
远东 谢
远东 谢 2023 年 3 月 13 日
回答済み: Abhijeet 2023 年 4 月 6 日
计算2.47/0.01时,输出247.0000,此时对结果使用ceil函数,得到的结果是278。但是计算2.471/0.001和24.7/0.1时均直接得到整数结果。

回答 (1 件)

Abhijeet
Abhijeet 2023 年 4 月 6 日
Hi,
You have encountered a round-off error that demonstrates a fundamental problem with the way computers deal with fractional numbers. Some numbers (in fact, "most" of them) cannot be represented exactly in binary form -- specifically, fractional numbers that are not powers of two. This will occur in any computer program using ANSI/IEEE standard math.
You can refer to this answer for the same.
Thanks

カテゴリ

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

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!