Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
GNU Units
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Infobox software | name = GNU Units | title = Units | logo = Heckert GNU white.svg | logo size = 125px | screenshot = <!-- [[File: ]] --> | caption = | collapsible = | author = | developer = [[GNU Project]] | released = <!-- {{Start date|YYYY|MM|DD|df=yes/no}} --> | discontinued = | latest release version = {{wikidata|property|preferred|references|edit|Q3093305|P348|P548=Q2804309}} | latest release date = {{wikidata|qualifier|preferred|single|Q3093305|P348|P548=Q2804309|P577}} | latest preview version = {{wikidata|property|preferred|references|edit|Q3093305|P348|P548=Q51930650}} | latest preview date = {{wikidata|qualifier|preferred|single|Q3093305|P348|P548=Q51930650|P577}} | repo = {{URL|http://web.cvs.savannah.gnu.org/viewvc/units/}}<!--Deliberately bypassing WikiData to avoid bug--> | programming language = | operating system = [[Linux]], [[FreeBSD]], [[NetBSD]], [[OpenBSD]], most Unix implementations, [[Microsoft Windows|Windows]] | platform = Included with some{{which|date=March 2017}} [[Linux distributions]]. Two Windows binary distributions are available; distribution for other platforms is source only. | size = 1.2 Megabytes (tar source) | language = | status = | genre = Utility | license = 2007: [[GNU General Public License|GPL-3.0-or-later]]{{efn|GPL-3.0-or-later since 2007-09-26 (1.87)}}<br />1997: [[GNU General Public License|GPL-2.0-or-later]]{{efn|GPL-2.0-or-later from 1997-01-14 (1.53) until 2006-11-11 (1.86)}} | website = }} {{Portal|Free and open-source software}} '''GNU Units''' is a [[cross-platform]] [[computer program]] for [[conversion of units]] of quantities. It has a database of [[Units of measurement|measurement units]], including [[List of strange units of measurement|esoteric]] and historical units. This for instance allows conversion of velocities specified in [[furlong]]s per [[fortnight]], and pressures specified in [[ton]]s 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 (software)#units .28Unix utility.29|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.<ref>{{cite web|title=Unix Seventh Edition Manual|publisher=Alcatel-Lucent Bell Labs|location=Murray Hill, NJ|url=http://plan9.bell-labs.com/7thEdMan/|year=1979|author=Bell Telephone Laboratories, Incorporated|access-date=2011-04-23|archive-date=2008-10-19|archive-url=https://web.archive.org/web/20081019172747/http://plan9.bell-labs.com/7thEdMan/|url-status=dead}} Online archive of the manual pages included with the [[Seventh Edition Unix]] distribution tapes.</ref> Source code for a version very similar to the original is available from the [[Heirloom Project]].<ref>{{cite web|title=Heirloom Project CVS repository|url=http://heirloom.cvs.sourceforge.net/viewvc/heirloom/heirloom/units/|access-date=2016-02-01}}</ref> === GNU implementation === GNU ''units'' includes several extensions to the original version,<ref>{{cite web|title=Units: A Unit Conversion Program and Scientific Calculator|publisher=Free Software Foundation, Inc.|location=Boston, MA|url=https://www.gnu.org/software/units/manual/units.html|year=2014|author=Mariano, Adrian|access-date=2014-03-29}} </ref> including * Exponents can be written with <code>^</code> or <code>**</code>. * Exponents can be larger than 9 if written with <code>^</code> or <code>**</code>. * Rational and decimal exponents are supported. * Sums of units (e.g., <code>{{nowrap|btu + ft lbf}}</code>) 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., <code>S</code> to <code>megohm</code>). * Parentheses for grouping are supported. This sometimes allows more natural expressions, such as in the example given in [[#Complex units expressions|Complex units expressions]]. * Roots of units (e.g., <code>{{nowrap|sqrt((lbf/inch) / lb)}}</code> can be computed. * Affine 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 (programming language)|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 (computing)|library]] interface and date conversion abilities. UDUNITS is considered the ''de facto'' program and library for variable unit conversion for [[netCDF]] files.<ref>As specified from several [[NetCDF]] conventions, e.g.: * '''COARDS'''—{{cite web |title=Conventions for the standardization of NetCDF files |date=1995-02-10 |url=http://ferret.wrc.noaa.gov/noaa_coop/coop_cdf_profile.html |access-date=2007-04-12 |archive-url=https://web.archive.org/web/20100527095818/http://ferret.wrc.noaa.gov/noaa_coop/coop_cdf_profile.html |archive-date=2010-05-27 |url-status=dead }} * '''CF'''—{{cite web |title=NetCDF Climate and Forecast (CF) Metadata Conventions |url=http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm |date=2014-03-29 }}</ref> === Version history === GNU Units version 2.19 was released on 31 May 2019, to reflect the [[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.<ref>(German language) [http://www.linux-magazin.de/NEWS/GNU-Units-2.0-berechnet-Feet-und-Inches « GNU Units 2.0 berechnet Feet und Inches »], ''linux-magazin.de'', 3 July 2012.</ref> 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 [[sine|sin]], [[cosine|cos]], [[arctangent|atan]], [[natural logarithm|ln]], [[exponential function|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 === <!-- GNU units version 2.10, Windows XP SP3 --> <pre> Currency exchange rates from www.timegenie.com on 2014-03-28 2729 units, 92 prefixes, 77 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(meter) ^ Unit not a root You have: sqrt(acre) You want: ft * 208.71033 / 0.0047913298 You have: 21 btu + 6500 ft lbf You want: btu * 29.352939 / 0.034068139 You have: _ You want: J * 30968.99 / 3.2290366e-005 You have: 3.277 hr You want: time 3 hr + 16 min + 37.2 sec You have: 1|2 inch You want: cm * 1.27 / 0.78740157 </pre> The underscore ('_') is used to indicate the result of the last successful unit conversion. === On the command line (non-interactive) === <!-- GNU units version 2.10, Windows XP SP3, cmd.exe --> <syntaxhighlight lang="doscon"> C:\>units "ten furlongs per fortnight" "kilometers per hour" * 0.0059871429 / 167.02458 </syntaxhighlight> <!-- GNU units version 2.10, Windows XP SP3, PTC MKS C shell --> <syntaxhighlight lang="console"> % units cup ounces conformability error 0.00023658824 m^3 0.028349523 kg </syntaxhighlight> === Complex units expressions === One form of the [[Darcy–Weisbach equation]] for [[fluid flow]] is : <math>\Delta P = \frac {8} {\pi^2} \rho fL \frac {Q^2} {d^5} \,,</math> 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 : <math>\Delta P = A_1 \,\rho fL \frac {Q^2} {d^5}</math> that would accept typical US units; the constant ''A''<sub>1</sub> could be determined manually using the [[Units conversion by factor-label|unit-factor method]], but it could be determined more quickly and easily using ''units'':<ref>GNU units version 2.10, Windows XP SP3, PTC MKS Korn shell</ref> <syntaxhighlight lang="console"> $ units "(8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)" psi * 43.533969 / 0.022970568 </syntaxhighlight> Crane Technical Paper No. 410,<ref> {{Cite book|title=''Technical Paper No. 410,'' Flow of Fluids through Valves, Fittings, and Pipe|publisher=Crane Co|location=New York|year=1985|url=http://www.flowoffluids.com/publications/crane-tp-410.aspx}} </ref> Eq. 3-5, gives the multiplicative value as 43.5. == See also == * [[Unified Code for Units of Measure]] == Notes == {{notelist}} == References == {{reflist}} == External links == * {{Official website}} * [https://linux.die.net/man/1/units Linux man page for units] * [http://units-in-java.sourceforge.net Java version of GNU units] * [http://gnuwin32.sourceforge.net/packages/units.htm GnuWin port of GNU units] * [http://heirloom.cvs.sourceforge.net/viewvc/heirloom/heirloom/units/ units source] from the [[Heirloom Project]] * [http://www.unitsconvert.com Online units converter based on GNU units] * [http://www.units-converter.com A simple online converter based on GNU units] * [http://www.unidata.ucar.edu/software/udunits/ UDUNITS] [[Category:Cross-platform software]] [[Category:Unix software]] [[Category:GNU Project software|Units]] [[Category:Free mathematics software]] [[Category:Units of measurement]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Main other
(
edit
)
Template:Notelist
(
edit
)
Template:Nowrap
(
edit
)
Template:Official website
(
edit
)
Template:Portal
(
edit
)
Template:Reflist
(
edit
)
Template:Template other
(
edit
)