# GNU Units

(Redirected from Units (software))
Developer(s) GNU Project 2.00[1] / July 2, 2012; 19 months ago GNU/Linux, FreeBSD, NetBSD, OpenBSD, Windows Utility GPLv3 Official website

GNU Units is a cross-platform computer program for conversion of units of quantities. It has a database of measurement units, including esoteric and historical units. This for instance allows conversion of velocities specified in furlongs per fortnight, and pressures specified in tons per acre. Output units are checked for consistency with the input, allowing verification of conversion of complex expressions.

## History

GNU Units has been initially written by Adrian Mariano as an implementation of the "units" UNIX utility, and distributed as free software.

### units (UNIX utility)

The original units program has been a standard part of Unix since the early Bell Laboratories versions.[2]

### Other implementations

UDUNITS is a similar utility program, except that it has an additional programming library interface and date conversion abilities. UDUNITS is considered the de facto program and library for variable unit conversion for netCDF files.[3]

### The GNU implementation

GNU units includes several extensions to the original version, including

• Exponents can be written with '^' or '**'.
• Exponents can be larger than 9 if written with '^' or '**'.
• Sums of units (e.g., btu + ft lbf) can be converted.
• Units that measure reciprocal dimensions can be converted (e.g., S to megohm).
• Parentheses for grouping are supported. The original version allowed only one solidus ('/'), which sometimes required rearrangement of complex expressions; the GNU version allows more natural expressions, such as in the example that follows.
• Roots of units (e.g., sqrt((lbf/inch) / lb) can be computed.
• Nonlinear units conversions (e.g., °F to °C) are supported.
• Functions such as sin, cos, and log are included.

The plain text database units.dat is a good reference in itself, as it is extensively commented and cites numerous sources.

### Version history

The new release of GNU Units, version 2.0, has been released on July 2, 2012. It can calculate sums of units, such as hours and minutes or feet and inches. In addition, the software now uses the UTF-8 encoding.[4] Since the new version can set units relative to environmental variables, units can be adjusted without changing the locale. In addition, the syntax has changed to define non-linear units, or also the database filename of your choice.

## Usage

Units will output the result of the conversion in two lines. Usually the first line (multiplication) is the desired result. The second line is the same conversion expressed as a division.

Units can also do math while converting, including several built in mathematical functions such as sin, cos, atan, log, exp, etc.

If you attempt to convert types of measurements that are incompatible units will print a conformability error message and display a reduced form of each measurement.

### Examples

The examples that follow show results from GNU units version 1.88; GNU units versions 1.84c and earlier defined a furlong in terms of the U.S. survey foot rather than international foot, and will give slightly different results than the examples that involve furlongs.

#### Interactive mode

2526 units, 72 prefixes, 56 nonlinear units

You have: 10 furlongs
You want: miles
* 1.25
/ 0.8
You have: 1 gallon + 3 pints
You want: quarts
* 5.5
/ 0.18181818
You have: sqrt(miles^2)
Definition: 1609.344 m
You have: 21 btu + 6500 ft lbf
You want: btu
* 29.352939
/ 0.034068139
You have:


### On the command line (non-interactive)=

 C:\>units "ten furlongs per fortnight" "kilometers per hour"
* 0.0059871429
/ 167.02458

 % units cup ounces
conformability error
0.00023658824 m^3
0.028349523 kg


#### Complex units expressions

One form of the Darcy–Weisbach equation for fluid flow is

$\Delta P = \frac {8} {\pi^2} \rho fL \frac {Q^2} {d^5} \,,$

where ΔP is the pressure drop, ρ is the mass density, f is the (dimensionless) friction factor, L is the length of the pipe, Q is the volumetric flow rate, and d is the pipe diameter. It might be desirable to have the equation in the form

$\Delta P = A_1 \,\rho fL \frac {Q^2} {d^5}$

that would accept typical US units; the constant A1 could be determined manually using the unit-factor method, but it could be determined more quickly and easily using units:

 \$ units "(8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)" psi
* 43.533969
/ 0.022970568


Crane Technical Paper No. 410,[5] Eq. 3-5, gives the multiplicative value as 43.5.

## References

1. ^ Mariano, Adrian (2012-07-02). "GNU Units 2.00". lists.gnu.org. Retrieved 2012-07-3.
2. ^ Bell Telephone Laboratories, Incorporated (1979). "Unix Seventh Edition Manual". Murray Hill, NJ: Alcatel-Lucent Bell Labs. Retrieved 2011-04-23. Online archive of the manual pages included with the Seventh Edition Unix distribution tapes.
3. ^ As specified from several NetCDF conventions, e.g.:
• COARDS
• CF
4. ^ (German language) « GNU Units 2.0 berechnet Feet und Inches  », linux-magazin.de, July 3, 2012.
5. ^ Technical Paper No. 410, Flow of Fluids through Valves, Fittings, and Pipe. New York: Crane Co. 1985.