title: GNU Units
text: # GNU Units
  
  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 was written by Adrian Mariano as an implementation of the units utility included with the Unix operating system. It was originally available under a permissive license. The GNU variant is distributed under the GPL although the FreeBSD project maintains a free fork of units from before the license change.
  
  ### units (Unix utility)
  
  The original units program has been a standard part of Unix since the early Bell Laboratories versions. Source code for a version very similar to the original is available from the Heirloom Project.
  
  ### 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 **.
  * Rational and decimal exponents are supported.
  * Sums of units (e.g., btu + ft lbf) can be converted.
  * Conversions can be made to sums of units, termed unit lists (e.g., from degrees to degrees, minutes, and seconds).
  * Units that measure reciprocal dimensions can be converted (e.g., S to megohm).
  * Parentheses for grouping are supported. This sometimes allows more natural expressions, such as in the example given in Complex units expressions.
  * 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, ln, log, and log2 are included.
  * A script for updating the currency conversions is included; the script requires Python.
  
  Units definitions, including nonlinear conversions and unit lists, are user extensible.
  
  The plain text database definitions.units is a good reference in itself, as it is extensively commented and cites numerous sources.
  
  ### 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.
  
  ### Version history
  
  GNU Units version 2.19 was released on 31 May 2019, to reflect the new 2019 revision of the SI; Version 2.14 released on 8 March 2017 fixed several minor bugs and improved support for building on Windows. Version 2.10, released on 26 March 2014, added support for rational exponents greater than one, and added the ability to save an interactive session in a file to provide a record of the conversions performed. Beginning with version 2.10, a 32-bit Windows binary distribution has been available on the project Web page (a 32-bit Windows port of version 1.87 has been available since 2008 as part of the GnuWin32 project).
  
  Version 2.02, released on 11 July 2013, added hexadecimal floating-point output and two other options to simplify changing the output format.
  
  Version 2.0, released on 2 July 2012, added the ability to convert to sums of units, such as hours and minutes or feet and inches. In addition, this release added support for UTF-8 encoding. Provision for locale-specific unit definitions was added. The syntax for defining non-linear units was changed, and added optional domain and range specifications. The names of the standard and personal units data files were changed, and the currency definitions were placed in a separate data file; a Python script for updating the currency definitions was added.
  
  The version history is covered in detail in the NEWS file included with the source distribution.
  
  ## 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 function as a general-purpose scientific calculator; it includes several built-in mathematical functions such as sin, cos, atan, ln, exp, etc.
  
  Attempting to convert types of measurements that are incompatible will cause units to print a conformability error message and display a reduced form of each measurement.
  
  ## Examples
  
  The examples that follow show results from GNU units version 2.10.
  
  ### Interactive mode
  
  The underscore ('_') is used to indicate the result of the last successful unit conversion.
  
  ### 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 $A_1$ could be determined manually using the unit-factor method, but it could be determined more quickly and easily using units:
  
  Crane Technical Paper No. 410, Eq. 3-5, gives the multiplicative value as 43.5.
  
  