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