About the calculation precise
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (1)
James Tursa
el 22 de Ag. de 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:
Categorías
Más información sobre Whos en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!