my @number = qw(3 3.555 3.222334 3.4 1 0); for my $float(@number) { $float = nearest(.001, $float); printf "%.3f\n", $float; }