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