in reply to Round a fraction

Found a way to round it safely:

my $frac = shift; if ($frac =~ /\..{5,}000.$/) { $frac =~ s/.$//; } elsif ($frac =~ /(\..{5,}999)(.)$/) { $frac = $frac + ( (10-$2) . "E-" . length($1)); } print "rounded to $frac";

note: $frac can be an integer; $frac must be positive