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
In reply to Re: Round a fraction
by fglock
in thread Round a fraction
by fglock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |