Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7915128c

Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt

  • ID 7915128cc09f9756439ab9216a82ada3870893c3
  • Vorgänger bf19eeda
  • Nachfolger 75f43bc1

round_amount: Anzahl Stellen nicht zu hoch werden lassen

Unterschiede anzeigen:

SL/Form.pm
982 982
  # part. If an overflow occurs then apply that overflow to the part
983 983
  # before the decimal sign as well using integer arithmetic again.
984 984

  
985
  my $amount_str = sprintf '%.*f', $places + 10, abs($amount);
985
  my $int_amount = int(abs $amount);
986
  my $str_places = max(min(10, 16 - length("$int_amount") - $places), $places);
987
  my $amount_str = sprintf '%.*f', $places + $str_places, abs($amount);
986 988

  
987 989
  return $amount unless $amount_str =~ m{^(\d+)\.(\d+)$};
988 990

  

Auch abrufbar als: Unified diff