```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Very weird resolution issue. Bug ????? Seriously !!
Date: Tue, 3 Mar 2009 21:10:29 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 18
Message-ID: <gok6c5\$19g\$1@fred.mathworks.com>
References: <goju5b\$nv4\$1@fred.mathworks.com> <gok3qm\$2gn\$1@fred.mathworks.com> <gok5db\$mqi\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1236114629 1328 172.30.248.35 (3 Mar 2009 21:10:29 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Mar 2009 21:10:29 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:522235

> What algorithm should I depend on then???

I almost always use a tolerance instead of comparing floating point numbers for exact equality.  Using the a from your example:

s1 = 0; for ii = 1:length(a(:,1)),s1 = s1 + a(ii,1)^2;end  % gives same as your c
s2 = 0; for ii = length(a(:,1)):-1:1,s2 = s2 + a(ii,1)^2;end  % gives same as b(1,1)
fprintf('\n    %18.18g\n\n',s2)
fprintf('\n    %18.18g\n\n',s1)

isequal(s1,s2) % No
abs(s1-s2)<20*eps  % Yes

XZj_L`DPRSZjqqLLjxjjNLXV0[WaTLZ`8[j%_LSPZjjZZM_YWNPTPLSdMY+
```