how to get correct value on division in matlab

2 次查看(过去 30 天)
I am dividing 60 by 88.8888888888889 in matlab. It is giving result as 0.675000000000000. But when I am doing the same calculation on a calculator, the result is 0.674999999999999.
How to get 0.674999999999999 as result using matlab. Please help.

回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2016-4-13
Use vpa function

dpb
dpb 2016-4-13
>> 60/88.8888888888889-4*eps(ans)
ans =
0.674999999999999
>>
Can't expect FP precision to be the same between Matlab and another computing platform; there can be differences even with the same computation of different computers owing to word sizes and implementation.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by