in reply to Re: How do you ++ a fraction?
in thread Round a fraction
Thanks.
(0.1 ** length($1)) could also be written:
("1E-" . length($1))
update: This is what I came up with:
$frac = shift; $frac =~ s/(\d+).$/$1/; # remove last digit & get fraction size $frac += "1E-" . length($1); # add 1E-(size) => 0.0001 print $frac;
Works for "0.123999", "10.12399" and ".12399"
The result is weird when the number does not have a fractional part, but that is not my case.
|
|---|