Info

This question is closed. Reopen it to edit or answer.

Imprecise addition in matlab R14SP2 under fedora 13, library mismatch?

1 view (last 30 days)
Hi. I am running a 32 bit matlab R14 SP2 on 64 bit fedora 13 (I use the -glnx86 architecture flag). When I do a simple calculation I am getting what looks like roundoff or significant digit errors. Example:
>> a = .43 + .33 + .52 + .58
a = 1.8600e+00 : so good so far!
>> a - 1.86
ans = -2.2204e-16 : should be 0
Obviously I shouldn't be having these errors. I have used matlab a long time without any such issues. But I did upgrade to fedora 13 a while ago so I'm wondering if there is some library mis-match. Has anyone seen such a problem? what is the solution? thanks. Larry
  1 Comment
Jan
Jan on 29 Sep 2011
This behaviour does not concern only your Matlab version and Linux. It appears in a C-program under Windows also.

Answers (1)

the cyclist
the cyclist on 29 Sep 2011
I suggest you take a look at the answers (especially the accepted one) here:
I'm a little surprised that you have not seen this behavior before, if you have been using MATLAB a long time.
  1 Comment
Walter Roberson
Walter Roberson on 29 Sep 2011
http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F

Community Treasure Hunt

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

Start Hunting!