in reply to Re: Where's that function
in thread Where's that function
my $num = 12.3456789; $num = substr($num, 0, index($num, '.') + 3); print $num; #prints 12.34
Also, here's another that is probably overkill:
use Math::Currency; my $num = 12.3456789; $num = Math::Currency->new($num);
This handles the rounding up/down of the number, where the preceding golf attempt does not. The original post did not ask for rounding, though.
|
|---|