The units are defined in an external data file. You can use the extensive data file that comes with this program, or you can provide your own data file to suit your needs.
You can use the program interactively with prompts, or you can use it from the command line.
2131 units, 53 prefixes, 24 nonlinear units
You have:
At the `You have:' prompt, type the quantity and units that you are converting from. For example, if you want to convert ten meters to feet, type `10 meters'. Next, `units' will print `You want:'. You should type the type of units you want to convert to. To convert to feet, you would type `feet'. Note that if the readline library was compiled in then the tab key can be used to complete unit names. See Readline support, for more information about readline.
The answer will be displayed in two ways. The first line of output, which is marked with a `*' to indicate multiplication, gives the result of the conversion you have asked for. The second line of output, which is marked with a `/' to indicate division, gives the inverse of the conversion factor. If you convert 10 meters to feet, `units' will print
* 32.808399
/ 0.03048
which tells you that 10 meters equals about 32.8 feet. The second number gives the conversion in the opposite direction. In this case, it tells you that 1 foot is equal to about 0.03 dekameters since the dekameter is 10 meters. It also tells you that 1/32.8 is about .03.
The `units' program prints the inverse because sometimes it is a more convenient number. In the example above, for example, the inverse value is an exact conversion: a foot is exactly .03048 dekameters. But the number given the other direction is inexact.
If you try to convert grains to pounds, you will see the following:
You have: grains
You want: pounds
* 0.00014285714
/ 7000
From the second line of the output you can immediately see that a grain is equal to a seven thousandth of a pound. This is not so obvious from the first line of the output. If you find the output format confusing, try using the `--verbose' option:
You have: grain
You want: aeginamina
grain = 0.00010416667 aeginamina
grain = (1 / 9600) aeginamina
If you request a conversion between units which measure reciprocal dimensions, then `units' will display the conversion results with an extra note indicating that reciprocal conversion has been done:
You have: 6 ohms
You want: siemens
reciprocal conversion
* 0.16666667
/ 6
Reciprocal conversion can be suppressed by using the `--strict' option. As usual, use the `--verbose' option to get more comprehensible output:
You have: tex
You want: typp
reciprocal conversion
1 / tex = 496.05465 typp
1 / tex = (1 / 0.0020159069) typp
You have: 20 mph
You want: sec/mile
reciprocal conversion
1 / 20 mph = 180 sec/mile
1 / 20 mph = (1 / 0.0055555556) sec/mile
If you enter incompatible unit types, the `units' program will print a message indicating that the units are not conformable and it will display the reduced form for each unit:
You have: ergs/hour
You want: fathoms kg^2 / day
conformability error
2.7777778e-11 kg m^2 / sec^3
2.1166667e-05 kg^2 m / sec
If you only want to find the reduced form or definition of a unit, simply press return at the `You want:' prompt. Here is an example:
You have: jansky
You want:
Definition: fluxunit = 1e-26 W/m^2 Hz = 1e-26 kg / s^2
The output from `units' indicates that the jansky is defined to be equal to a fluxunit which in turn is defined to be a certain combination of watts, meters, and hertz. The fully reduced (and in this case somewhat more cryptic) form appears on the far right.
Some named units are treated as dimensionless in some situations. These include the radian and steradian. These units will be treated as equal to 1 in units conversions. Power is equal to torque times angular velocity. This conversion can only be performed if the radian is dimensionless.
You have: (14 ft lbf) (12 radians/sec)
You want: watts
* 227.77742
/ 0.0043902509
Note that named dimensionaless units are not treated as dimensionless in other contexts. They cannot be used as exponents so for example, `meter^radian' is not allowed.
If you want a list of options you can type `?' at the `You want:' prompt. The program will display a list of named units which are conformable with the unit that you entered at the `You have:' prompt above. Note that conformable unit combinations will not appear on this list.
Typing `help' at either prompt displays a short help message. You can also type `help' followed by a unit name. This will invoke a pager on the units data base at the point where that unit is defined. You can read the definition and comments that may give more details or historical information about the unit.
If you type
units '2 liters' 'quarts'
then `units' will print
* 2.1133764
/ 0.47317647
and then exit. The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters.
If the conversion is successful, then `units' will return success (0) to the calling environment. If `units' is given non-conformable units to convert, it will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment.
When `units' is invoked with only one argument, it will print out the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined.
You have: cm^3
You want: gallons
* 0.00026417205
/ 3785.4118
You have: arabicfoot * arabictradepound * force
You want: ft lbf
* 0.7296
/ 1.370614
Multiplication of units can be specified by using spaces, or an asterisk (`*'). If `units' is invoked with the `--product' option then the hyphen (`-') also acts as a multiplication operator. Division of units is indicated by the slash (`/') or by `per'.
You have: furlongs per fortnight
You want: m/s
* 0.00016630986
/ 6012.8727
Multiplication has a higher precedence than division and is evaluated left to right, so `m/s * s/day' is equivalent to `m / s s day' and has dimensions of length per time cubed. Similarly, `1/2 meter' refers to a unit of reciprocal length equivalent to .5/meter, which is probably not what you would intend if you entered that expression. You can indicate division of numbers with the vertical dash (`|'). This operator has the highest precedence so the square root of two thirds could be written `2|3^1|2'.
You have: 1|2 inch
You want: cm
* 1.27
/ 0.78740157
Parentheses can be used for grouping as desired.
You have: (1/2) kg / (kg/meter)
You want: league
* 0.00010356166
/ 9656.0833
Prefixes are defined separately from base units. In order to get centimeters, the units database defines `centi-' and `c-' as prefixes. Prefixes can appear alone with no unit following them. An exponent applies only to the immediately preceding unit and its prefix so that `cm^3' or `centimeter^3' refer to cubic centimeters but `centi*meter^3' refers to hundredths of cubic meters. Only one prefix is permitted per unit, so `micromicrofarad' will fail, but `micro*microfarad' will work, as will `micro microfarad'..
For `units', numbers are just another kind of unit. They can appear as many times as you like and in any order in a unit expression. For example, to find the volume of a box which is 2 ft by 3 ft by 12 ft in steres, you could do the following:
You have: 2 ft 3 ft 12 ft
You want: stere
* 2.038813
/ 0.49048148
You have: $ 5 / yard
You want: cents / inch
* 13.888889
/ 0.072
And the second example shows how the dollar sign in the units conversion can precede the five. Be careful: `units' will interpret `$5' with no space as equivalent to dollars^5.
Outside of the SI system, it is often desirable to add values of different units together. You may also wish to use `units' as a calculator that keeps track of units. Sums of conformable units are written with the `+' character.
You have: 2 hours + 23 minutes + 32 seconds
You want: seconds
* 8612
/ 0.00011611705
You have: 12 ft + 3 in
You want: cm
* 373.38
/ 0.0026782366
You have: 2 btu + 450 ft lbf
You want: btu
* 2.5782804
/ 0.38785542
The expressions which are added together must reduce to identical expressions in primitive units, or an error message will be displayed:
You have: 12 printerspoint + 4 heredium
^
Illegal sum of non-conformable units
Historically `-' has been used for products of units, which complicates its iterpretation in `units'. Because `units' provides several other ways to obtain unit products, and because `-' is a subtraction operator in general algebraic expressions, `units' treats the binary `-' as a subtraction operator by default. This behavior can be altered using the `--product' option which causes `units' to treat the binary `-' operator as a product operator. Note that when `-' is a multiplication operator it has the same precedence as `*', but when `-' is a subtraction operator it has the lower precedence as the addition operator.
When `-' is used as a unary operator it negates its operand. Regardless of the `units' options, if `-' appears after `(' or after `+' then it will act as a negation operator. So you can always compute 20 degrees minus 12 minutes by entering `20 degrees + -12 arcmin'. You must use this construction when you define new units because you cannot know what options will be in force when your definition is processed.
The `+' character sometimes appears in exponents like `3.43e+8'. This leads to an ambiguity in an expression like `3e+2 yC'. The unit `e' is a small unit of charge, so this can be regarded as equivalent to `(3e+2) yC' or `(3 e)+(2 yC)'. This ambiguity is resolved by always interpreting `+' as part of an exponent if possible.
Several built in functions are provided: `sin', `cos', `tan', `ln', `log', `log2', `exp', `acos', `atan' and `asin'. The `sin', `cos', and `tan' functions require either a dimensionless argument or an argument with dimensions of angle.
You have: sin(30 degrees)
You want:
Definition: 0.5
You have: sin(pi/2)
You want:
Definition: 1
You have: sin(3 kg)
^
Unit not dimensionless
The other functions on the list require dimensionless arguments. The inverse trigonometric functions return arguments with dimensions of angle.
If you wish to take roots of units, you may use the `sqrt' or `cuberoot' functions. These functions require that the argument have the appropriate root. Higher roots can be obtained by using fractional exponents:
You have: sqrt(acre)
You want: feet
* 208.71074
/ 0.0047913202
You have: (400 W/m^2 / stefanboltzmann)^(1/4)
You have:
Definition: 289.80882 K
You have: cuberoot(hectare)
^
Unit not a root
Nonlinear units are represented using functional notation. They make possible nonlinear unit conversions such temperature. This is different from the linear units that convert temperature differences. Note the difference below. The absolute temperature conversions are handled by units starting with `temp', and you must use functional notation. The temperature differences are done using units starting with `deg' and they do not require functional notation.
You have: tempF(45)
You want: tempC
7.2222222
You have: 45 degF
You want: degC
* 25
/ 0.04
Think of `tempF(x)' not as a function but as a notation which indicates that `x' should have units of `tempF' attached to it. See Nonlinear units. The first conversion shows that if it's 45 degrees Fahrehneit outside it's 7.2 degrees Celsius. The second conversions indicates that a change of 45 degrees Fahrenheit corresponds to a change of 25 degrees Celsius.
Some other examples of nonlinears units are ring size and wire gauge. There are numerous different gauges and ring sizes. See the units database for more details. Note that wire gauges with multiple zeroes are signified using negative numbers where two zeroes is -1. Alternatively, you can use the synonyms `g00', `g000', and so on that are defined in the units database.
You have: wiregauge(11)
You want: inches
* 0.090742002
/ 11.020255
You have: brwiregauge(g00)
You want: inches
* 0.348
/ 2.8735632
You have: 1 mm
You want: wiregauge
18.201919
units [OPTIONS] [FROM-UNIT [TO-UNIT]]
If the FROM-UNIT and TO-UNIT are omitted, then the program will use interactive prompts to determine which conversions to perform. See Interactive use. If both FROM-UNIT and TO-UNIT are given, `units' will print the result of that single conversion and then exit. If only FROM-UNIT appears on the command line, `units' will display the definition of that unit and exit. Units specified on the command line will need to be quoted to protect them from shell interpretation and to group them into two arguments. See Command line use.
The following options allow you to read in an alternative units file, check your units file, or change the output format:
Many constants of nature are defined, including these:
pi ratio of circumference to diameter c speed of light e charge on an electron force acceleration of gravity mole Avogadro's number water pressure per unit height of water Hg pressure per unit height of mercury au astronomical unit k Boltzman's constant mu0 permeability of vacuum epsilon0 permitivity of vacuum G gravitational constant mach speed of soundThe database includes atomic masses for all of the elements and numerous other constants. Also included are the densities of various ingredients used in baking so that `2 cups flour_sifted' can be converted to `grams'. This is not an exhaustive list. Consult the units data file to see the complete list, or to see the definitions that are used.
The unit `pound' is a unit of mass. To get force, multiply by the force conversion unit `force' or use the shorthand `lbf'. (Note that `g' is already taken as the standard abbreviation for the gram.) The unit `ounce' is also a unit of mass. The fluid ounce is `fluidounce' or `floz'. British capacity units that differ from their US counterparts, such as the British Imperial gallon, are prefixed with `br'. Currency is prefixed with its country name: `belgiumfranc', `britainpound'.
The US Survey foot, yard, and mile can be obtained by using the `US' prefix. These units differ slightly from the international length units. They were in general use until 1959, and are still used for geographic surveys. The acre is officially defined in terms of the US Survey foot. If you want an acre defined according to the international foot, use `intacre'. The difference between these units is about 4 parts per million. The British also used a slightly different length measure before 1959. These can be obtained with the prefix `UK'.
When searching for a unit, if the specified string does not appear exactly as a unit name, then the `units' program will try to remove a trailing `s' or a trailing `es'. If that fails, `units' will check for a prefix. All of the standard metric prefixes are defined.
To find out what units and prefixes are available, read the standard units data file.