Next: , Previous: , Up: Units Conversion   [Contents][Index]

## 2 Interacting with `units`

To invoke `units` for interactive use, type units at your shell prompt. The program will print something like this:

```Currency exchange rates from FloatRates (USD base) on 2023-07-08
3612 units, 109 prefixes, 122 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 units you want to convert to. To convert to feet, you would type feet. If the `readline` library was compiled in, then tab will complete unit names. See Readline Support, for more information about `readline`. To quit the program type quit or exit at either prompt.

The result 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 0.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 0.03048 dekameters. But the number given the other direction is inexact.

If you 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 that 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 Enter 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. If the ultimate definition and the fully reduced form are identical, the latter is not shown:

```You have: B
You want:
Definition: byte = 8 bit
```

The fully reduced form is shown if it and the ultimate definition are equivalent but not identical:

```You have: N
You want:
Definition: newton = kg m / s^2 = 1 kg m / s^2
```

Some named units are treated as dimensionless in some situations. These units 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
```

It is also possible to compute roots and other non-integer powers of dimensionless units; this allows computations such as the altitude of geosynchronous orbit:

```You have: cuberoot(G earthmass / (circle/siderealday)^2) - earthradius
You want: miles
* 22243.267
/ 4.4957425e-05
```

Named dimensionless units are not treated as dimensionless in other contexts. They cannot be used as exponents so for example, ‘meter^radian’ is forbidden.

If you want a list of options you can type ? at the ‘You want: prompt. The program will display a list of named units that are conformable with the unit that you entered at the ‘You have: prompt above. 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 your pager allows, you may want to scroll backwards, e.g. with ‘b’, because sometimes a longer comment about a unit or group of units will appear before the definition. You can generally quit out of the pager by pressing ‘q’.

Typing search text will display a list of all of the units whose names contain text as a substring along with their definitions. This may help in the case where you aren’t sure of the right unit name.

Next: Using `units` Non-Interactively, Previous: Overview of `units`, Up: Units Conversion   [Contents][Index]