Prty::Formatter - Formatierung von Werten
Prty::Object
$x = $class->normalizeNumber($x);
Entferne unnötige Nullen von einer Zahl, forciere als Dezimaltrennzeichen einen Punkt (anstelle eines Komma) und liefere das Resultat zurück.
123.456000 -> 123.456 70.00 -> 70 0.0 -> 0 -0.0 -> 0 007 -> 7 23,7 -> 23.7
$str = $class->readableNumber($x); $str = $class->readableNumber($x,$sep);
Formatiere eine Zahl $x mit Tausender-Trennzeichen $sep. Per Default ist $sep ein Punkt (.). Handelt es sich bei $x um eine Zahl mit Nachkomma-Stellen, wird der Punkt durch ein Komma (,) ersetzt.
.
,
1 -> 1 12 -> 12 12345 -> 12.345 -12345678 -> -12.345.678 -12345.678 -> -12.345,678
$y = $class->roundTo($x,$n); $y = $class->roundTo($x,$n,$normalize);
Runde $x auf $n Nachkommastellen und liefere das Resultat zurück.
Ist $normalize "wahr", wird die Zahl nach der Rundung mit normalizeNumber() normalisiert.
Bei $n > 0 rundet die Methode mittels
$y = sprintf '%.*f',$n,$x;
bei $n == 0 mittels roundToInt().
1.092
Frank Seitz, http://fseitz.de/
Copyright (C) 2016 Frank Seitz
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Prty, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prty
CPAN shell
perl -MCPAN -e shell install Prty
For more information on module installation, please visit the detailed CPAN module installation guide.