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



At 1:49 pm -0500 13/10/03, Bill Stephenson wrote:
 I've got a script that takes numbers similar to those below and then rounds
 them and adds them together using code similar to what is below.

     my $item_1 = "1.655";
     my $item_2 = "1.755";
     my $rnd_1 = (sprintf qq~%.2f~, $item_1);
     my $rnd_2 = (sprintf qq~%.2f~, $item_2);
     print "$rnd_1, $rnd_2";


The code above prints this result (system 10.1.5, perl 5.6.0):


1.66, 1.75

But shouldn't it be:

1.66, 1.76

Reply via email to