WTF ?
Paul Orrock
paulo at digitalcraftsmen.net
Wed Jan 10 12:39:25 GMT 2007
I've tried this on a couple of machines running perl 5.8.6 and 5.8.8
for ($i=1.2;$i<4;$i+=0.05) {
print $i . "\n";
}
Starts off fine, I get
1.2
1.25
1.3 etc
Suddenly I get
3.4
3.45
3.5
3.54999999999999
3.59999999999999
3.64999999999999
3.69999999999999
Can anyone explain why this is ? I get the correct (in my eyes) 1dp /
2dp result with 0.04 and 0.06 but 0.05 ends up to 14dp ?
Yours confusedly,
Paul
More information about the london.pm
mailing list