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