# part. If an overflow occurs then apply that overflow to the part
# before the decimal sign as well using integer arithmetic again.
- my $amount_str = sprintf '%.*f', $places + 10, abs($amount);
+ my $int_amount = int(abs $amount);
+ my $str_places = max(min(10, 16 - length("$int_amount") - $places), $places);
+ my $amount_str = sprintf '%.*f', $places + $str_places, abs($amount);
return $amount unless $amount_str =~ m{^(\d+)\.(\d+)$};
is($::form->round_amount(198.90 * 0.75, 1), '149.2', '198.90 * 0.75 @ 1');
is($::form->round_amount(198.90 * 0.75, 0), '149', '198.90 * 0.75 @ 0');
+is($::form->round_amount(19610.975, 2), '19610.98', '19610.975 @ 2');
+
# Negative values
is($::form->round_amount(-1.05, 2), '-1.05', '-1.05 @ 2');
is($::form->round_amount(-1.05, 1), '-1.1', '-1.05 @ 1');