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