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