rhubarbpie at poetworld.net wrote:
> I'm a Perl novice and hope this is a proper channel for a simple 
> question.  Why does the following decrement incorrectly below 10?  It 
> works with $i -- or $i -= .5.  This is part of a larger script and I've 
> made a workaround, but I'm still curious.
>   
Start $i from 100 and you'll notice that it happens for numbers greater 
than 10. The reason for this is that certain numbers cannot be 
represented accurately with the floating point representation your 
computer architecture and data type use. IEEE 754 is a standard that 
addresses this so try reading up on that if you're really interested. 
Any who, this is even worse in C with a float.

float i;
for (i = 13; i >= 1; i -= .1){
printf("i equals %f\n", i);
}

i equals 13.000000
i equals 12.900000
i equals 12.799999
i equals 12.699999
i equals 12.599998
i equals 12.499998
i equals 12.399998
i equals 12.299997
i equals 12.199997
i equals 12.099997
i equals 11.999996
i equals 11.899996
i equals 11.799995
i equals 11.699995
i equals 11.599995
i equals 11.499994
i equals 11.399994
i equals 11.299994
i equals 11.199993
i equals 11.099993
i equals 10.999992
i equals 10.899992
i equals 10.799992
i equals 10.699991
i equals 10.599991
i equals 10.499990
i equals 10.399990
i equals 10.299990
i equals 10.199989
i equals 10.099989

But works perfectly with (even starting from 100)

double i;
for (i = 13; i >= 1; i -= .1){
printf("i equals %lf\n", i);

Perl has a different way of representing float point numbers it seems so 
look into a module that supports extra precision floats.