Probably silly floating comparison question

dams dams at gentoo.org
Tue Aug 8 11:12:41 BST 2006


Le Tue, 8 Aug 2006 10:46:39 +0100 (BST),
london.pm at welikegoats.com a écrit :

> On Tue, 8 Aug 2006, David Leadbeater wrote:
> 
> > london.pm at welikegoats.com wrote:
> > [..]
> >> I assume this is a rounding error with floating point values. How
> >> can I make it do what I would expect it to do, which is make the
> >> first one finish with 2.1?
> >
> > while("$i" < 2)
> 
> Why does this work?
> 

I think that's because $i is seen as a string, (one character, '2'),
then transformed in number (2 exactly), before the comparison. Thus the
rounding error has disappeared




More information about the london.pm mailing list