www.delorie.com/gnu/docs/units/units_2.html   search  
 
Buy GNU books!


Units: A Unit Conversion Program

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [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:

 
    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.

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.

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003