Path: news.mathworks.com!not-for-mail
From: "Xing Li" <xli71@syr.edu>
Newsgroups: comp.soft-sys.matlab
Subject: help for while loop
Date: Sun, 30 Dec 2012 21:14:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 12
Message-ID: <kbqar0$7co$1@newscl01ah.mathworks.com>
Reply-To: "Xing Li" <xli71@syr.edu>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1356902048 7576 172.30.248.35 (30 Dec 2012 21:14:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 30 Dec 2012 21:14:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3787377
Xref: news.mathworks.com comp.soft-sys.matlab:785625

I have a very simple while loop, which was supposed to break right away until n = 10. But this loop never break because n = 10.1 in the end. How could this happened?  

n = 0;
flag = 0;
while (flag == 0)
if( n < 10)
    n = n + 0.1;
   if(n == 10)
    flag = 1;
   end
end
end