X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/61cbd09d2fe81a2961a8073d5881a00c2abcfa03..bebca3b60f8c019b9acbc436da7437d67dc19e67:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index 9045d78ca..c59669c41 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -822,6 +822,7 @@ sub format_amount { my $force_places = defined $places && $places >= 0; $amount = $self->round_amount($amount, abs $places) if $force_places; + $neg = 0 if $amount == 0; # don't show negative zero $amount = sprintf "%.*f", ($force_places ? $places : 10), abs $amount; # 6 is default for %fa # before the sprintf amount was a number, afterwards it's a string. because of the dynamic nature of perl @@ -981,7 +982,9 @@ sub round_amount { # 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+)$};