on 10/13/03 3:07 PM, John Delacour at [EMAIL PROTECTED] wrote: > Don't ask me why but this does solve your problem (which happens also > in 5.8.0): > > @ls = qw(1.655 1.755) ; > for (@ls) { > $_ += 0.00000000000001; > printf "%.2f$/" , $_; > } > > > JD
Thanks JD! That seems to work pretty good. I still don't quite get what's going on here so I'll do some further testing to see If I can catch any more odd (imho) behavior. For grins, run the included code and check the different results for each sub routine. -- Bill Stephenson www.PerlHelp.com 1-417-546-5593 #################### start code #################### #!/usr/bin/perl -w use strict; my @stuff = qw "1.055 1.155 1.255 1.355 1.455 1.555 1.655 1.755 1.855 1.955 1.1055"; &round1; &round2; &round3; sub round1 { print "=============== round1 ================\n"; foreach my $num1 (@stuff) { print "$num1 rounded to -> "; my $result1 = $num1; $result1 = ($result1*100); $result1=(int $result1 + ( $result1 > 0 ? 0.5 : -0.5 ))/100; $result1 = (sprintf qq~%.2f~, $result1); print "$result1\n"; } } sub round2 { print "=============== round2 ================\n"; foreach my $num2 (@stuff) { print "$num2 rounded to -> "; my $result2 = $num2; $result2 = ($result2 + .00001); $result2 = (sprintf qq~%.2f~, $result2); print "$result2\n"; } } sub round3 { print "=============== round3 ================\n"; foreach my $num3 (@stuff) { print "$num3 rounded to -> "; my $result3 = $num3; $result3 = ($result3 + 0.0000000000000001); $result3 = (sprintf qq~%.2f~, $result3); print "$result3\n"; } } ##################### end code #####################