Annotation of src/usr.bin/units/units.1, Revision 1.27
1.27 ! jsg 1: .\" $OpenBSD: units.1,v 1.26 2014/09/08 01:27:55 schwarze 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.27 ! jsg 19: .Dd $Mdocdate: September 8 2014 $
1.4 deraadt 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.19 jmc 27: .Op Fl qv
1.4 deraadt 28: .Op Fl f Ar filename
1.25 jmc 29: .Op Oo Ar count Oc Ar from-unit to-unit
1.4 deraadt 30: .Sh DESCRIPTION
1.10 aaron 31: The
32: .Nm
1.11 pjanzen 33: program converts quantities expressed in various scales to
1.10 aaron 34: their equivalents in other scales.
35: The
36: .Nm
37: program can only handle multiplicative scale changes.
38: It cannot convert Celsius
39: to Fahrenheit, for example.
1.11 pjanzen 40: It also does not handle logarithmic units such as bels.
1.24 jmc 41: .Pp
42: .Nm
43: 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
1.24 jmc 56: That is, one meter equals roughly 3.28 feet
57: (or, conversely, one foot is roughly equal to 0.3 meters),
58: and one gallon is roughly equal to 3785 cubic cm.
59: .Pp
1.13 pjanzen 60: The
61: .Nm
62: program can handle numbers as well:
1.15 jmc 63: .Bd -literal -offset indent
64: You have: 60 miles/hr
65: You want: km/hr
66: * 96.56064
67: / 0.010356187
1.13 pjanzen 68:
1.24 jmc 69: You have: 100 USD
70: You want: 10 euro
71: * 7.4354971
72: / 0.13449
1.15 jmc 73: .Ed
1.13 pjanzen 74: .Pp
1.24 jmc 75: In other words, 60 miles per hour is about 96.6 km/hr,
76: and 100 US dollars will get you seven 10-Euro notes.
1.4 deraadt 77: .Pp
1.10 aaron 78: The options are as follows:
79: .Bl -tag -width Ds
80: .It Fl f Ar filename
81: Specifies the name of the units data file to load.
82: .It Fl q
83: Suppresses prompting of the user for units and the display of statistics
84: about the number of units loaded.
85: .It Fl v
86: Prints the version number.
1.25 jmc 87: .It Oo Ar count Oc Ar from-unit to-unit
1.10 aaron 88: Allows a single unit conversion to be done directly from the command line.
89: No prompting will occur.
90: The units program will print out
91: only the result of this single conversion.
1.25 jmc 92: A
93: .Ar count
94: can be given to specify multiples of
95: .Ar from-unit .
1.10 aaron 96: .El
97: .Pp
1.8 aaron 98: Powers of units can be specified using the
99: .Ql ^
100: character as shown in
101: the example, or by simple concatenation:
1.9 pjanzen 102: .Sq cm3
1.8 aaron 103: is equivalent to
1.9 pjanzen 104: .Sq cm^3 .
1.1 deraadt 105: Multiplication of units can be specified by using spaces, a dash or
1.10 aaron 106: an asterisk.
107: Division of units is indicated by the slash
1.8 aaron 108: .Pq Ql / .
109: Note that multiplication has a higher precedence than division, so
1.9 pjanzen 110: .Sq m/s/s
1.8 aaron 111: is the same as
1.9 pjanzen 112: .Sq m/s^2
1.8 aaron 113: or
1.9 pjanzen 114: .Sq m/s s .
1.1 deraadt 115: If the user enters incompatible unit types, the units program will
116: print a message indicating that the units are not conformable and
117: it will display the reduced form for each unit:
1.15 jmc 118: .Bd -literal -offset indent
119: You have: ergs/hour
120: You want: fathoms kg^2 / day
121: conformability error
122: 2.7777778e-11 kg m^2 / sec^3
123: 2.1166667e-05 kg^2 m / sec
124: .Ed
1.4 deraadt 125: .Pp
1.10 aaron 126: The conversion information is read from a units data file.
127: The default file includes definitions for most familiar units,
128: abbreviations and metric prefixes.
129: Some constants of nature included are:
1.23 jmc 130: .Pp
131: .Bl -tag -width mercuryXXX -offset indent -compact
1.4 deraadt 132: .It pi
133: ratio of circumference to diameter
134: .It c
135: speed of light
136: .It e
137: charge on an electron
138: .It g
139: acceleration of gravity
140: .It force
141: same as g
142: .It mole
143: Avogadro's number
144: .It water
1.9 pjanzen 145: pressure per unit height of water (at 4 C)
1.4 deraadt 146: .It mercury
147: pressure per unit height of mercury
1.9 pjanzen 148: .It ao
149: Bohr radius
150: .It AU
1.4 deraadt 151: astronomical unit
152: .El
153: .Pp
1.9 pjanzen 154: .Sq Pound
1.10 aaron 155: is a unit of mass.
156: Compound names are run together so
1.9 pjanzen 157: .Sq poundforce
1.10 aaron 158: is a unit of force.
159: British units that differ from their US counterparts are prefixed with
1.9 pjanzen 160: .Sq br ,
161: and currency is prefixed with its country name:
162: .Sq belgiumfranc ,
163: .Sq britainpound .
164: When searching for
1.1 deraadt 165: a unit, if the specified string does not appear exactly as a unit
1.9 pjanzen 166: name, then the units program will try to remove a trailing
167: .Sq s
168: or a trailing
169: .Sq es
170: and check again for a match.
1.4 deraadt 171: .Pp
1.1 deraadt 172: All of these definitions can be read in the standard units file, or you
1.10 aaron 173: can supply your own file.
174: A unit is specified on a single line by
175: giving its name and an equivalence.
176: One should be careful to define
1.1 deraadt 177: new units in terms of old ones so that a reduction leads to the
1.8 aaron 178: primitive units which are marked with
1.16 jmc 179: .Ql \&!
1.8 aaron 180: characters.
1.1 deraadt 181: The units program will not detect infinite loops that could be caused
182: by careless unit definitions.
1.4 deraadt 183: .Pp
1.8 aaron 184: Prefixes are defined in the same way as standard units, but with
1.10 aaron 185: a trailing dash at the end of the prefix name.
186: Prefixes are applied
1.9 pjanzen 187: after the longest matching unit name is found; for example,
188: .Dq nmile
189: is taken to be a nautical mile rather than a nanomile.
1.12 aaron 190: .Sh FILES
191: .Bl -tag -width /usr/share/misc/units.lib
192: .It Pa /usr/share/misc/units.lib
193: the standard units library
194: .El
1.21 jmc 195: .Sh SEE ALSO
196: .Rs
197: .%I International Bureau of Weights and Measures
198: .%T The International System of Units
1.27 ! jsg 199: .%U https://www.bipm.org/utils/common/pdf/si_brochure_8.pdf
1.21 jmc 200: .Re
201: .Rs
202: .%R ISO 4217
203: .%T Codes for the representation of currencies and funds
204: .%D 2008
1.22 jmc 205: .Re
206: .Rs
207: .%R ISO/IEC 80000
208: .%T Quantities and units \(em Part 13: Information science and technology
1.21 jmc 209: .Re
1.12 aaron 210: .Sh AUTHORS
1.26 schwarze 211: .An Adrian Mariano Aq Mt adrian@cam.cornell.edu
212: or
213: .Aq Mt mariano@geom.umn.edu
1.4 deraadt 214: .Sh BUGS
1.8 aaron 215: The effect of including a
216: .Ql /
217: in a prefix is surprising.
1.4 deraadt 218: .Pp
1.9 pjanzen 219: Exponents of units entered by the user can be only one digit.
1.1 deraadt 220: You can work around this by multiplying several terms.
1.4 deraadt 221: .Pp
1.10 aaron 222: The user must use
223: .Ql |
224: to indicate division of numbers and
225: .Ql /
226: to indicate division of symbols.
227: This distinction should not be necessary.
1.9 pjanzen 228: .Pp
229: Prefixes specified without a unit are treated as dimensionless quantities.
230: This can lead to confusion when some prefixes are also defined as units
1.10 aaron 231: (e.g., m).
232: For example, Tera- / Giga- is 1000, but one Tesla (T) is 10,000
1.9 pjanzen 233: Gauss (G).
234: .Pp
1.17 jmc 235: Some non-SI units have multiple definitions (e.g., barrel, calorie) and
1.10 aaron 236: others have changed over time (e.g., cubit).
237: In particular, monetary values fluctuate.
1.4 deraadt 238: .Pp
1.1 deraadt 239: The program contains various arbitrary limits on the length
240: of the units converted and on the length of the data file.
1.4 deraadt 241: .Pp
1.1 deraadt 242: The program should use a hash table to store units so that
243: it doesn't take so long to load the units list and check
1.8 aaron 244: for duplication.