Clear Filters
Clear Filters

how to get correct value on division in matlab

2 views (last 30 days)
Anil Verma
Anil Verma on 13 Apr 2016
Answered: dpb on 13 Apr 2016
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.

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 13 Apr 2016
Use vpa function

dpb
dpb on 13 Apr 2016
>> 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.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!