About the calculation precise
Show older comments
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?
Accepted Answer
More Answers (1)
James Tursa
on 22 Aug 2013
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:
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!