NAME Number::Format::Metric - Format number with metric prefix, with some options VERSION This document describes version 0.603 of Number::Format::Metric (from Perl distribution Number-Format-Metric), released on 2025-09-24. SYNOPSIS use Number::Format::Metric qw(format_metric); # precision option format_metric(14 , {base=>10}); # => "14.0" format_metric(14 , {base=>10, precision=>0}); # => "14" # base 2 vs base 10 format_metric(12001 , {base=> 2, precision=>1}); # => "11.7k" format_metric(12001 , {base=>10, precision=>3}); # => "12.001ki" format_metric(-0.0017, {base=>10}); # => "-1.7m" format_metric(1.26e6 , {base=>10}); # => "1.3Mi" # don't use "i" mark for base 10 format_metric(12001 , {base=>10, precision=>3, i_mark=>0}); # => "12.001k" # uppercase_k option format_metric(12001 , {base=>10, precision=>3, uppercase_k=>1}); # => "12.001Ki" # additional_prefix option format_metric(12001 , {base=> 2, precision=>1, additional_prefix=>"b"}); # => "11.7kb" format_metric(12001 , {base=>10, precision=>1, additional_prefix=>"bps"}); # => "12.0kbps" # latin_only option format_metric(2.3e-6 , {base=>10, precision=>1, additional_prefix=>"g"}); # => "2.3μg" format_metric(2.3e-6 , {base=>10, precision=>1, additional_prefix=>"g", latin_only=>1}); # => "2.3mcg" FUNCTIONS None exported by default but all of them exportable. format_metric($num, \%opts) => STR Format $num using metric prefix. Locale settings are respected (this module uses locale). Might produce non-Latin Unicode characters (e.g. "μ" for 1e-6 prefix), unless if you set the "latin_only" option, in which case "μ" will be shown as "mc". Known options: * base => INT (either 2 or 10, default: 2) * precision => INT * i_mark => BOOL (default: 1) Give "i" suffix to prefixes when in base 10 for k, M, G, T, and so on. * uppercase_k => BOOL (default: 0) When set to true, will use "K" instead of "k" for kilo. * latin_only => BOOL (default: 0) When set to true, will use "mc" instead of "μ" for micro. * additional_prefix => STR String to add after the prefix, e.g. "b" (for byte), "g" (for gram), etc. HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . SEE ALSO Other number formatting modules: Number::Format, Format::Human::Bytes, Number::Bytes::Human. AUTHOR perlancar CONTRIBUTOR Steven Haryanto CONTRIBUTING To contribute, you can send patches by email/via RT, or send pull requests on GitHub. Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via: % prove -l If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me. COPYRIGHT AND LICENSE This software is copyright (c) 2025 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.