1Units(3)              User Contributed Perl Documentation             Units(3)
2
3
4

NAME

6       Math::Calc::Units - Human-readable unit-aware calculator
7

SYNOPSIS

9           use Math::Calc::Units qw(calc readable convert equal);
10
11           print "It will take ".calc("10MB/(384Kbps)")." to download\n";
12
13           my @alternative_descriptions = readable("10MB/(384Kbps)");
14
15           print "A week is ".convert("1 week", "seconds")." long\n";
16
17           if (equal("$rate bytes / sec", "1 MB/sec")) { ... };
18

DESCRIPTION

20       "Math::Calc::Units" is a simple calculator that keeps track of units.
21       It currently handles combinations of byte sizes and duration only,
22       although adding any other multiplicative types is easy. Any unknown
23       type is treated as a unique user type (with some effort to map English
24       plurals to their singular forms).
25
26       The primary intended use is via the "ucalc" script that prints out all
27       of the "readable" variants of a value. For example, "3 bytes" will only
28       produce "3 byte", but "3 byte / sec" produces the original along with
29       "180 byte / minute", "10.55 kilobyte / hour", etc.
30
31       The "Math::Calc::Units" interface only provides for string-based
32       computations, which could result in a large loss of precision for some
33       applications. If you need the exact result, you may pass in an extra
34       parameter 'exact' to "calc" or "convert", causing them to return a
35       2-element list containing the numerical result and a string describing
36       the units of that result:
37
38           my ($value, $units) = convert("10MB/sec", "GB/day");
39
40       (In scalar context, they just return the numeric value.)
41
42   Examples of use
43       ·   Estimate transmission rates (e.g., 10MB at 384 kilobit/sec)
44
45       ·   Estimate performance characteristics (e.g., disk I/O rates)
46
47       ·   Figure out how long something will take to complete
48
49       I tend to work on performance-sensitive code that involves a lot of
50       network and disk traffic, so I wrote this tool after I became very sick
51       of constantly converting KB/sec to GB/day when trying to figure out how
52       long a run is going to take, or what the theoretical maximum
53       performance would be if we were 100% disk bound. Now I can't live
54       without it.
55
56   Contraindications
57       If you are just trying to convert from one unit to another, you'll
58       probably be better off with "Math::Units" or "Convert::Units". This
59       module really only makes sense when you're converting to and from
60       human-readable values.
61

AUTHOR

63       Steve Fink <sfink@cpan.org>
64

SEE ALSO

66       ucalc, Math::Units, Convert::Units.
67
68
69
70perl v5.28.1                      2009-08-04                          Units(3)
Impressum