xref: /openbsd/usr.bin/units/units.1 (revision 1821443c)
1.\" $OpenBSD: units.1,v 1.16 2003/09/02 18:50:07 jmc Exp $
2.\" converted to new format by deraadt@openbsd.org
3.\"
4.\" Copyright (c) 1993 by Adrian Mariano (adrian@cam.cornell.edu)
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. The name of the author may not be used to endorse or promote products
12.\"    derived from this software without specific prior written permission.
13.\" Disclaimer:  This software is provided by the author "as is".  The author
14.\" shall not be liable for any damages caused in any way by this software.
15.\"
16.\" I would appreciate (though I do not require) receiving a copy of any
17.\" improvements you might make to this program.
18.\"
19.Dd July 14, 1993
20.Dt UNITS 1
21.Os
22.Sh NAME
23.Nm units
24.Nd conversion program
25.Sh SYNOPSIS
26.Nm units
27.Op Fl f Ar filename
28.Op Fl q
29.Op Fl v
30.Ar from-unit
31.Ar to-unit
32.Sh DESCRIPTION
33The
34.Nm
35program converts quantities expressed in various scales to
36their equivalents in other scales.
37The
38.Nm
39program can only handle multiplicative scale changes.
40It cannot convert Celsius
41to Fahrenheit, for example.
42It also does not handle logarithmic units such as bels.
43It works interactively by prompting the user for input:
44.Pp
45.Bd -literal -offset indent
46You have: meters
47You want: feet
48        * 3.2808399
49        / 0.3048
50
51You have: cm^3
52You want: gallons
53        * 0.00026417205
54        / 3785.4118
55.Ed
56.Pp
57The
58.Nm
59program can handle numbers as well:
60.Pp
61.Bd -literal -offset indent
62You have: 60 miles/hr
63You want: km/hr
64        * 96.56064
65        / 0.010356187
66
67You have: 5 austriaschilling
68You want: 100 italylira
69        * 7.0357114
70        / 0.14213204
71.Ed
72.Pp
73In other words, 60 miles per hour is about 96.6 km/hr, and 5 Austrian
74Schillings will get you seven 100-Lira coins.
75.Pp
76The options are as follows:
77.Bl -tag -width Ds
78.It Fl f Ar filename
79Specifies the name of the units data file to load.
80.It Fl q
81Suppresses prompting of the user for units and the display of statistics
82about the number of units loaded.
83.It Fl v
84Prints the version number.
85.It Ar from-unit Ar to-unit
86Allows a single unit conversion to be done directly from the command line.
87No prompting will occur.
88The units program will print out
89only the result of this single conversion.
90.El
91.Pp
92Powers of units can be specified using the
93.Ql ^
94character as shown in
95the example, or by simple concatenation:
96.Sq cm3
97is equivalent to
98.Sq cm^3 .
99Multiplication of units can be specified by using spaces, a dash or
100an asterisk.
101Division of units is indicated by the slash
102.Pq Ql / .
103Note that multiplication has a higher precedence than division, so
104.Sq m/s/s
105is the same as
106.Sq m/s^2
107or
108.Sq m/s s .
109If the user enters incompatible unit types, the units program will
110print a message indicating that the units are not conformable and
111it will display the reduced form for each unit:
112.Pp
113.Bd -literal -offset indent
114You have: ergs/hour
115You want: fathoms kg^2 / day
116conformability error
117        2.7777778e-11 kg m^2 / sec^3
118        2.1166667e-05 kg^2 m / sec
119.Ed
120.Pp
121The conversion information is read from a units data file.
122The default file includes definitions for most familiar units,
123abbreviations and metric prefixes.
124Some constants of nature included are:
125.Bl -tag -width mercury
126.It pi
127ratio of circumference to diameter
128.It c
129speed of light
130.It e
131charge on an electron
132.It g
133acceleration of gravity
134.It force
135same as g
136.It mole
137Avogadro's number
138.It water
139pressure per unit height of water (at 4 C)
140.It mercury
141pressure per unit height of mercury
142.It ao
143Bohr radius
144.It AU
145astronomical unit
146.El
147.Pp
148.Sq Pound
149is a unit of mass.
150Compound names are run together so
151.Sq poundforce
152is a unit of force.
153British units that differ from their US counterparts are prefixed with
154.Sq br ,
155and currency is prefixed with its country name:
156.Sq belgiumfranc ,
157.Sq britainpound .
158When searching for
159a unit, if the specified string does not appear exactly as a unit
160name, then the units program will try to remove a trailing
161.Sq s
162or a trailing
163.Sq es
164and check again for a match.
165.Pp
166All of these definitions can be read in the standard units file, or you
167can supply your own file.
168A unit is specified on a single line by
169giving its name and an equivalence.
170One should be careful to define
171new units in terms of old ones so that a reduction leads to the
172primitive units which are marked with
173.Ql \&!
174characters.
175The units program will not detect infinite loops that could be caused
176by careless unit definitions.
177.Pp
178Prefixes are defined in the same way as standard units, but with
179a trailing dash at the end of the prefix name.
180Prefixes are applied
181after the longest matching unit name is found; for example,
182.Dq nmile
183is taken to be a nautical mile rather than a nanomile.
184.Sh FILES
185.Bl -tag -width /usr/share/misc/units.lib
186.It Pa /usr/share/misc/units.lib
187the standard units library
188.El
189.Sh AUTHORS
190Adrian Mariano (adrian@cam.cornell.edu or mariano@geom.umn.edu)
191.Sh BUGS
192The effect of including a
193.Ql /
194in a prefix is surprising.
195.Pp
196Exponents of units entered by the user can be only one digit.
197You can work around this by multiplying several terms.
198.Pp
199The user must use
200.Ql |
201to indicate division of numbers and
202.Ql /
203to indicate division of symbols.
204This distinction should not be necessary.
205.Pp
206Prefixes specified without a unit are treated as dimensionless quantities.
207This can lead to confusion when some prefixes are also defined as units
208(e.g., m).
209For example, Tera- / Giga- is 1000, but one Tesla (T) is 10,000
210Gauss (G).
211.Pp
212Some non-SI units have multiple definitions (e.g, barrel, calorie) and
213others have changed over time (e.g., cubit).
214In particular, monetary values fluctuate.
215.Pp
216The program contains various arbitrary limits on the length
217of the units converted and on the length of the data file.
218.Pp
219The program should use a hash table to store units so that
220it doesn't take so long to load the units list and check
221for duplication.
222