About the calculation precise
显示 更早的评论
The precise of calculation has a problem when I add 60.425 with 0.425. The exact value should be 60.85, however I just got 60.8499999..., which affects my following calculation. How I can avoid such problem?
采纳的回答
更多回答(1 个)
James Tursa
2013-8-22
For your particular example, none of the values can be represented in IEEE double exactly:
>> num2strexact(60.425)
ans =
6.04249999999999971578290569595992565155029296875e1
>> num2strexact(0.425)
ans =
0.424999999999999988897769753748434595763683319091796875
>> num2strexact(60.425+0.425)
ans =
6.0849999999999994315658113919198513031005859375e1
You can find num2strexact here:
类别
在 帮助中心 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!