Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / units / units.1
1 .\" $FreeBSD: src/usr.bin/units/units.1,v 1.8.2.5 2001/07/22 12:40:40 dd Exp $
2 .Dd July 14, 1993
3 .Dt UNITS 1
4 .Os
5 .Sh NAME
6 .Nm units
7 .Nd conversion program
8 .Sh SYNOPSIS
9 .Nm
10 .Op Fl f Ar filename
11 .Op Fl qv
12 .Op Ar from-unit to-unit
13 .Sh OPTIONS
14 The following options are available:
15 .Bl -tag -width indent
16 .It Fl f Ar filename
17 Specify the name of the units data file to load.
18 .It Fl q
19 Suppress prompting of the user for units and the display of statistics
20 about the number of units loaded.
21 .It Fl v
22 Print the version number.
23 .It Ar from-unit to-unit
24 Allow a single unit conversion to be done directly from the command
25 line.  The program will not print prompts.  It will print out the
26 result of the single specified conversion.
27 .El
28 .Sh DESCRIPTION
29 The
30 .Nm
31 program converts quantities expressed in various scales to
32 their equivalents in other scales.  The
33 .Nm
34 program can only
35 handle multiplicative scale changes.  It cannot convert Celsius
36 to Fahrenheit, for example.  It works interactively by prompting
37 the user for input:
38 .Bd -literal
39     You have: meters
40     You want: feet
41             * 3.2808399
42             / 0.3048
43
44     You have: cm^3
45     You want: gallons
46             * 0.00026417205
47             / 3785.4118
48
49     You have: meters/s
50     You want: furlongs/fortnight
51             * 6012.8848
52             / 0.00016630952
53
54     You have: 1|2 inch
55     You want: cm
56             * 1.27
57             / 0.78740157
58 .Ed
59 .Pp
60 Powers of units can be specified using the '^' character as shown in
61 the example, or by simple concatenation: 'cm3' is equivalent to 'cm^3'.
62 Multiplication of units can be specified by using spaces, a dash or
63 an asterisk.  Division of units is indicated by the slash ('/').
64 Note that multiplication has a higher precedence than division,
65 so 'm/s/s' is the same as 'm/s^2' or 'm/s s'.  Division of numbers
66 must be indicated using the vertical bar ('|').  To convert half a
67 meter, you would write '1|2 meter'.  If you write '1/2 meter' then the
68 units program would interpret that as equivalent to '0.5/meter'.
69 If you enter incompatible unit types, the units program will
70 print a message indicating that the units are not conformable and
71 it will display the reduced form for each unit:
72 .Bd -literal
73     You have: ergs/hour
74     You want: fathoms kg^2 / day
75     conformability error
76             2.7777778e-11 kg m^2 / sec^3
77             2.1166667e-05 kg^2 m / sec
78 .Ed
79 .Pp
80 The conversion information is read from a units data file.  The default
81 file includes definitions for most familiar units, abbreviations and
82 metric prefixes.  Some constants of nature included are:
83 .Pp
84 .Bl -inset -offset indent -compact
85 .It "pi ratio of circumference to diameter
86 .It "c  speed of light
87 .It "e  charge on an electron
88 .It "g  acceleration of gravity
89 .It "force      same as g
90 .It "mole       Avogadro's number
91 .It "water      pressure per unit height of water
92 .It "mercury    pressure per unit height of mercury
93 .It "au astronomical unit
94 .El
95 .Pp
96 The unit 'pound' is a unit of mass.  Compound names are run together
97 so 'pound force' is a unit of force.  The unit 'ounce' is also a unit
98 of mass.  The fluid ounce is 'floz'.  British units that differ from
99 their US counterparts are prefixed with 'br', and currency is prefixed
100 with its country name: 'belgiumfranc', 'britainpound'.  When searching
101 for a unit, if the specified string does not appear exactly as a unit
102 name, then
103 .Nm
104 will try to remove a trailing 's' or a
105 trailing 'es' and check again for a match.
106 .Pp
107 To find out what units are available read the standard units file.
108 If you want to add your own units you can supply your own file.
109 A unit is specified on a single line by
110 giving its name and an equivalence.  Be careful to define
111 new units in terms of old ones so that a reduction leads to the
112 primitive units which are marked with '!' characters.
113 The
114 .Nm
115 program will not detect infinite loops that could be caused
116 by careless unit definitions.  Comments in the unit definition file
117 begin with a '/' character at the beginning of a line.
118 .Pp
119 Prefixes are defined in the same was as standard units, but with
120 a trailing dash at the end of the prefix name.  If a unit is not found
121 even after removing trailing 's' or 'es', then it will be checked
122 against the list of prefixes.  Prefixes will be removed until a legal
123 base unit is identified.
124 .Pp
125 Here is an example of a short units file that defines some basic
126 units.
127 .Pp
128 .Bl -inset -offset indent -compact
129 .It "m  !a!
130 .It "sec        !b!
131 .It "micro-     1e-6
132 .It "minute     60 sec
133 .It "hour       60 min
134 .It "inch       0.0254 m
135 .It "ft 12 inches
136 .It "mile       5280 ft
137 .El
138 .Sh BUGS
139 The effect of including a '/' in a prefix is surprising.
140 .Pp
141 Exponents entered by the user can be only one digit.
142 You can work around this by multiplying several terms.
143 .Pp
144 The user must use | to indicate division of numbers and / to
145 indicate division of symbols.  This distinction should not
146 be necessary.
147 .Pp
148 The program contains various arbitrary limits on the length
149 of the units converted and on the length of the data file.
150 .Pp
151 The program should use a hash table to store units so that
152 it doesn't take so long to load the units list and check
153 for duplication.
154 .Sh FILES
155 .Bl -tag -width /usr/share/misc/units.lib -compact
156 .It Pa /usr/share/misc/units.lib
157 the standard units library
158 .El
159 .Sh AUTHORS
160 .An Adrian Mariano Aq adrian@cam.cornell.edu