Probably silly floating comparison question
london.pm at dgl.cx
Tue Aug 8 10:58:39 BST 2006
london.pm at welikegoats.com wrote:
> 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?
It loses precision, $i is greater than 2 in the internal form, but
when converted to a string and back to a floating point value it is
while($i <= 2.000000001) also works for the same reason.
More information about the london.pm