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