Name : perl-Number-Format
| |
Version : 1.76
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.1.1
| Date : 2023-07-20 15:23:37
|
Group : Unspecified
| Source RPM : perl-Number-Format-1.76-lp155.1.1.src.rpm
|
Size : 0.07 MB
| |
Packager : https://www_suse_com/
| |
Summary : Perl extension for formatting numbers
|
Description :
These functions provide an easy means of formatting numbers in a manner suitable for displaying to the user.
There are two ways to use this package. One is to declare an object of type Number::Format, which you can think of as a formatting engine. The various functions defined here are provided as object methods. The constructor \'new()\' can be used to set the parameters of the formatting engine. Valid parameters are:
THOUSANDS_SEP - character inserted between groups of 3 digits DECIMAL_POINT - character separating integer and fractional parts MON_THOUSANDS_SEP - like THOUSANDS_SEP, but used for format_price MON_DECIMAL_POINT - like DECIMAL_POINT, but used for format_price INT_CURR_SYMBOL - character(s) denoting currency (see format_price()) DECIMAL_DIGITS - number of digits to the right of dec point (def 2) DECIMAL_FILL - boolean; whether to add zeroes to fill out decimal NEG_FORMAT - format to display negative numbers (def ``-x\'\') KILO_SUFFIX - suffix to add when format_bytes formats kilobytes (trad) MEGA_SUFFIX - \" \" \" \" \" \" megabytes (trad) GIGA_SUFFIX - \" \" \" \" \" \" gigabytes (trad) KIBI_SUFFIX - suffix to add when format_bytes formats kibibytes (iec) MEBI_SUFFIX - \" \" \" \" \" \" mebibytes (iec) GIBI_SUFFIX - \" \" \" \" \" \" gibibytes (iec)
They may be specified in upper or lower case, with or without a leading hyphen ( - ).
If \'THOUSANDS_SEP\' is set to the empty string, format_number will not insert any separators.
The defaults for \'THOUSANDS_SEP\', \'DECIMAL_POINT\', \'MON_THOUSANDS_SEP\', \'MON_DECIMAL_POINT\', and \'INT_CURR_SYMBOL\' come from the POSIX locale information (see perllocale). If your POSIX locale does not provide \'MON_THOUSANDS_SEP\' and/or \'MON_DECIMAL_POINT\' fields, then the \'THOUSANDS_SEP\' and/or \'DECIMAL_POINT\' values are used for those parameters. Formerly, POSIX was optional but this caused problems in some cases, so it is now required. If this causes you hardship, please contact the author of this package at < SwPrAwMAATTcpan.org> (remove \"SPAM\" to get correct email address) for help.
If any of the above parameters are not specified when you invoke \'new()\', then the values are taken from package global variables of the same name (e.g. \'$DECIMAL_POINT\' is the default for the \'DECIMAL_POINT\' parameter). If you use the \':vars\' keyword on your \'use Number::Format\' line (see non-object-oriented example below) you will import those variables into your namesapce and can assign values as if they were your own local variables. The default values for all the parameters are:
THOUSANDS_SEP = \',\' DECIMAL_POINT = \'.\' MON_THOUSANDS_SEP = \',\' MON_DECIMAL_POINT = \'.\' INT_CURR_SYMBOL = \'USD\' DECIMAL_DIGITS = 2 DECIMAL_FILL = 0 NEG_FORMAT = \'-x\' KILO_SUFFIX = \'K\' MEGA_SUFFIX = \'M\' GIGA_SUFFIX = \'G\' KIBI_SUFFIX = \'KiB\' MEBI_SUFFIX = \'MiB\' GIBI_SUFFIX = \'GiB\'
Note however that when you first call one of the functions in this module _without_ using the object-oriented interface, further setting of those global variables will have no effect on non-OO calls. It is recommended that you use the object-oriented interface instead for fewer headaches and a cleaner design.
The \'DECIMAL_FILL\' and \'DECIMAL_DIGITS\' values are not set by the Locale system, but are definable by the user. They affect the output of \'format_number()\'. Setting \'DECIMAL_DIGITS\' is like giving that value as the \'$precision\' argument to that function. Setting \'DECIMAL_FILL\' to a true value causes \'format_number()\' to append zeroes to the right of the decimal digits until the length is the specified number of digits.
\'NEG_FORMAT\' is only used by \'format_negative()\' and is a string containing the letter \'x\', where that letter will be replaced by a positive representation of the number being passed to that function. \'format_number()\' and \'format_price()\' utilize this feature by calling \'format_negative()\' if the number was less than 0.
\'KILO_SUFFIX\', \'MEGA_SUFFIX\', and \'GIGA_SUFFIX\' are used by \'format_bytes()\' when the value is over 1024, 1024*1024, or 1024*1024*1024, respectively. The default values are \"K\", \"M\", and \"G\". These apply in the default \"traditional\" mode only. Note: TERA or higher are not implemented because of integer overflows on 32-bit systems.
\'KIBI_SUFFIX\', \'MEBI_SUFFIX\', and \'GIBI_SUFFIX\' are used by \'format_bytes()\' when the value is over 1024, 1024*1024, or 1024*1024*1024, respectively. The default values are \"KiB\", \"MiB\", and \"GiB\". These apply in the \"iso60027\"\" mode only. Note: TEBI or higher are not implemented because of integer overflows on 32-bit systems.
The only restrictions on \'DECIMAL_POINT\' and \'THOUSANDS_SEP\' are that they must not be digits and must not be identical. There are no restrictions on \'INT_CURR_SYMBOL\'.
For example, a German user might include this in their code:
use Number::Format; my $de = new Number::Format(-thousands_sep => \'.\', -decimal_point => \',\', -int_curr_symbol => \'DEM\'); my $formatted = $de->format_number($number);
Or, if you prefer not to use the object oriented interface, you can do this instead:
use Number::Format qw(:subs :vars); $THOUSANDS_SEP = \'.\'; $DECIMAL_POINT = \',\'; $INT_CURR_SYMBOL = \'DEM\'; my $formatted = format_number($number);
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-N/15.5/noarch |