1.\" $NetBSD: units.1,v 1.11 2002/04/02 18:08:28 atatat Exp $ 2.Dd December 18, 2001 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.Oo 13.Op Ar count 14.Ar from-unit to-unit 15.Oc 16.Sh DESCRIPTION 17The units program converts quantities expression in various scales to 18their equivalents in other scales. The units program can only 19handle multiplicative scale changes. It cannot convert Centigrade 20to Fahrenheit, for example. 21.Pp 22The following options are supported: 23.Bl -tag -width "from-unit to-unit" -offset indent 24.It Fl f Ar filename 25Specifies the name of the units data file to load. 26.It Fl q 27Suppresses prompting of the user for units and the display of statistics 28about the number of units loaded. 29.It Fl v 30Prints the version number. 31.It Ar from-unit Ar to-unit 32Allows a single unit conversion to be done directly from the command 33line. No prompting will occur. The units program will print out 34only the result of this single conversion. The 35.Ar count 36argument can be prepended to the 37.Ar from-unit 38or it can be separate. 39.El 40.Pp 41.Nm 42works interactively by prompting 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.Ed 54.Pp 55Powers of units can be specified using the 56.Dq \&^ 57character as shown in the example, or by simple concatenation: 58.Dq cm3 59is equivalent to 60.Dq cm^3 . 61Multiplication of units can be specified by using spaces, a dash or 62an asterisk. Division of units is indicated by the slash 63.Pq Sq \&/ . 64Note that multiplication has a higher precedence than division, 65so 66.Dq m/s/s 67is the same as 68.Dq m/s^2 69or 70.Dq "m/s s" . 71If the user enters incompatible unit types, the units program will 72print a message indicating that the units are not conformable and 73it will display the reduced form for each unit: 74.Bd -literal 75 You have: ergs/hour 76 You want: fathoms kg^2 / day 77 conformability error 78 2.7777778e-11 kg m^2 / sec^3 79 2.1166667e-05 kg^2 m / sec 80.Ed 81.Pp 82The conversion information is read from a units data file. The default 83file includes definitions for most familiar units, abbreviations and 84metric prefixes. Some constants of nature included are: 85.Bl -tag -width mercury -compact -offset indent 86.It pi 87ratio of circumference to diameter 88.It c 89speed of light 90.It e 91charge on an electron 92.It g 93acceleration of gravity 94.It force 95same as g 96.It mole 97Avogadro's number 98.It water 99pressure per unit height of water 100.It mercury 101pressure per unit height of mercury 102.It au 103astronomical unit 104.El 105.Pp 106.Dq pound 107is a unit of mass. Compound names are run together 108so 109.Dq poundforce 110is a unit of force. British units that differ from their 111US counterparts are prefixed with 112.Dq br , 113and currency is prefixed with 114its country name: 115.Dq belgiumfranc , 116.Dq britainpound . 117When searching for 118a unit, if the specified string does not appear exactly as a unit 119name, then the units program will try to remove a trailing 120.Dq s 121or a trailing 122.Dq es 123and check again for a match. 124.Pp 125All of these definitions can be read in the standard units file, or you 126can supply your own file. A unit is specified on a single line by 127giving its name and an equivalence. One should be careful to define 128new units in terms of old ones so that a reduction leads to the 129primitive units which are marked with 130.Sq \&! 131characters. 132The units program will not detect infinite loops that could be caused 133by careless unit definitions. 134.Pp 135Prefixes are defined in the same was as standard units, but with 136a trailing dash at the end of the prefix name. 137.Sh FILES 138.Bl -tag -width /usr/share/misc/units.lib -compact 139.It Pa /usr/share/misc/units.lib 140the standard units library 141.El 142.Sh AUTHORS 143.An Adrian Mariano Aq adrian@cam.cornell.edu 144or 145.Aq mariano@geom.umn.edu 146.Sh BUGS 147The effect of including a 148.Sq \&/ 149in a prefix is surprising. 150.Pp 151Exponents entered by the user can be only one digit. 152You can work around this by multiplying several terms. 153.Pp 154The user must use 155.Sq \&| 156to indicate division of numbers and 157.Sq \&/ 158to indicate division of symbols. This distinction should not 159be necessary. 160.Pp 161The program contains various arbitrary limits on the length 162of the units converted and on the length of the data file. 163.Pp 164The program should use a hash table to store units so that 165it doesn't take so long to load the units list and check 166for duplication. 167