The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Prty::Formatter - Formatierung von Werten

BASE CLASS

Prty::Object

METHODS

Zahlen

normalizeNumber() - Normalisiere Zahldarstellung

Synopsis

    $x = $class->normalizeNumber($x);

Description

Entferne unnötige Nullen von einer Zahl, forciere als Dezimaltrennzeichen einen Punkt (anstelle eines Komma) und liefere das Resultat zurück.

Example

    123.456000 -> 123.456
    70.00 -> 70
    0.0 -> 0
    -0.0 -> 0
    007 -> 7
    23,7 -> 23.7

readableNumber() - Zahl mit Trenner an Tausender-Stellen

Synopsis

    $str = $class->readableNumber($x);
    $str = $class->readableNumber($x,$sep);

Description

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.

Example

    1 -> 1
    12 -> 12
    12345 -> 12.345
    -12345678 -> -12.345.678
    -12345.678 -> -12.345,678

roundTo() - Runde Zahl auf n Nachkommastellen

Synopsis

    $y = $class->roundTo($x,$n);
    $y = $class->roundTo($x,$n,$normalize);

Description

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().

VERSION

1.096

AUTHOR

Frank Seitz, http://fseitz.de/

COPYRIGHT

Copyright (C) 2016 Frank Seitz

LICENSE

This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.