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