GNU Units

Last updated
Units
Developer(s) GNU Project
Stable release
2.23 [1]   OOjs UI icon edit-ltr-progressive.svg / 18 February 2024
Repository web.cvs.savannah.gnu.org/viewvc/units/
Operating system Linux, FreeBSD, NetBSD, OpenBSD, most Unix implementations, Windows
Platform Included with some[ which? ] Linux distributions. Two Windows binary distributions are available; distribution for other platforms is source only.
Size 1.2 Megabytes (tar source)
Type Utility
License 2007: GPL-3.0-or-later [lower-alpha 1]
1997: GPL-2.0-or-later [lower-alpha 2]
Website www.gnu.org/software/units/   OOjs UI icon edit-ltr-progressive.svg

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.

Contents

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. [2] Source code for a version very similar to the original is available from the Heirloom Project. [3]

GNU implementation

GNU units includes several extensions to the original version, [4] including

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. [5]

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. [6] 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

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 

The underscore ('_') is used to indicate the result of the last successful unit conversion.

On the command line (non-interactive)

C:\>units "ten furlongs per fortnight""kilometers per hour"        * 0.0059871429        / 167.02458
% unitscupounces conformability error        0.00023658824 m^3        0.028349523 kg

Complex units expressions

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

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

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

$ 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, [8] Eq. 3-5, gives the multiplicative value as 43.5.

See also

Notes

  1. GPL-3.0-or-later since 2007-09-26 (1.87)
  2. GPL-2.0-or-later from 1997-01-14 (1.53) until 2006-11-11 (1.86)

Related Research Articles

The British thermal unit (Btu) is a measure of heat, which is a form of energy. It was originally defined as the amount of heat required to raise the temperature of one pound of water by one degree Fahrenheit. It is also part of the United States customary units. The SI unit for energy is the joule (J); one Btu equals about 1,055 J.

<span class="mw-page-title-main">Bash (Unix shell)</span> GNU replacement for the Bourne shell

Bash, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed for the GNU Project by Brian Fox. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of rebirth.

<span class="mw-page-title-main">GNU</span> Free software collection

GNU is an extensive collection of free software, which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operating systems popularly known as Linux. Most of GNU is licensed under the GNU Project's own General Public License (GPL).

<span class="mw-page-title-main">GNU Debugger</span> Source-level debugger

The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, Assembly, C, C++, D, Fortran, Haskell, Go, Objective-C, OpenCL C, Modula-2, Pascal, Rust, and partially others.

<span class="mw-page-title-main">Ghostscript</span> Interpreter for the PostScript language

Ghostscript is a suite of software based on an interpreter for Adobe Systems' PostScript and Portable Document Format (PDF) page description languages. Its main purposes are the rasterization or rendering of such page description language files, for the display or printing of document pages, and the conversion between PostScript and PDF files.

<span class="mw-page-title-main">Wget</span> Computer command line program

GNU Wget is a computer program that retrieves content from web servers. It is part of the GNU Project. Its name derives from "World Wide Web" and "get". It supports downloading via HTTP, HTTPS, and FTP.

dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files. On Unix, device drivers for hardware and special device files appear in the file system just like normal files; dd can also read and/or write from/to these files, provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII and EBCDIC text encodings.

<span class="mw-page-title-main">Scanner Access Now Easy</span> Open source scanner application programming interface

Scanner Access Now Easy (SANE) is an open-source application programming interface (API) that provides standardized access to any raster image scanner hardware. The SANE API is public domain. It is commonly used on Linux.

bc, for basic calculator, is "an arbitrary-precision calculator language" with syntax similar to the C programming language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.

pax is an archiving utility available for various operating systems and defined since 1995. Rather than sort out the incompatible options that have crept up between tar and cpio, along with their implementations across various versions of Unix, the IEEE designed a new archive utility pax that could support various archive formats with useful options from both archivers. The pax command is available on Unix and Unix-like operating systems and on IBM i, and Microsoft Windows NT until Windows 2000.

In Unix and Unix-like operating systems, iconv is a command-line program and a standardized application programming interface (API) used to convert between different character encodings. "It can convert from any of these encodings to any other, through Unicode conversion."

df (Unix) Standard Unix command

df is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access. df is typically implemented using the statfs or statvfs system calls.

The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.

Source Code Control System (SCCS) is a version control system designed to track changes in source code and other text files during the development of a piece of software. This allows the user to retrieve any of the previous versions of the original source code and the changes which are stored. It was originally developed at Bell Labs beginning in late 1972 by Marc Rochkind for an IBM System/370 computer running OS/360.

GNU Readline is a software library that provides in-line editing and history capabilities for interactive programs with a command-line interface, such as Bash. It is currently maintained by Chet Ramey as part of the GNU Project.

more (command) Terminal pager available on various operating systems

In computing, more is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.

This comparison only covers software licenses which have a linked Wikipedia article for details and which are approved by at least one of the following expert groups: the Free Software Foundation, the Open Source Initiative, the Debian Project and the Fedora Project. For a list of licenses not specifically intended for software, see List of free-content licences.

Linux began in 1991 as a personal project by Finnish student Linus Torvalds to create a new free operating system kernel. The resulting Linux kernel has been marked by constant growth throughout its history. Since the initial release of its source code in 1991, it has grown from a small number of C files under a license prohibiting commercial distribution to the 4.15 version in 2018 with more than 23.3 million lines of source code, not counting comments, under the GNU General Public License v2 with a syscall exception meaning anything that uses the kernel via system calls are not subject to the GNU GPL.

<span class="mw-page-title-main">GNU General Public License</span> Series of free software licenses

The GNU General Public Licenses are a series of widely used free software licenses, or copyleft licenses, that guarantee end users the freedoms to run, study, share, and modify the software. The license was the first copyleft for general use and was originally written by Richard Stallman, the founder of the Free Software Foundation (FSF), for the GNU Project. The license grants the recipients of a computer program the rights of the Free Software Definition. The licenses in the GPL series are all copyleft licenses, which means that any derivative work must be distributed under the same or equivalent license terms. It is more restrictive than the Lesser General Public License and even further distinct from the more widely-used permissive software licenses such as BSD, MIT, and Apache.

XZ Utils is a set of free software command-line lossless data compressors, including the programs lzma and xz, for Unix-like operating systems and, from version 5.0 onwards, Microsoft Windows. For compression/decompression the Lempel–Ziv–Markov chain algorithm (LZMA) is used. XZ Utils started as a Unix port of Igor Pavlov's LZMA-SDK that has been adapted to fit seamlessly into Unix environments and their usual structure and behavior.

References

  1. https://ftp.gnu.org/gnu/units/ . Retrieved 8 March 2024.{{cite web}}: Missing or empty |title= (help)
  2. Bell Telephone Laboratories, Incorporated (1979). "Unix Seventh Edition Manual". Murray Hill, NJ: Alcatel-Lucent Bell Labs. Archived from the original on 2008-10-19. Retrieved 2011-04-23. Online archive of the manual pages included with the Seventh Edition Unix distribution tapes.
  3. "Heirloom Project CVS repository" . Retrieved 2016-02-01.
  4. Mariano, Adrian (2014). "Units: A Unit Conversion Program and Scientific Calculator". Boston, MA: Free Software Foundation, Inc. Retrieved 2014-03-29.
  5. As specified from several NetCDF conventions, e.g.:
  6. (German language) « GNU Units 2.0 berechnet Feet und Inches », linux-magazin.de, 3 July 2012.
  7. GNU units version 2.10, Windows XP SP3, PTC MKS Korn shell
  8. Technical Paper No. 410, Flow of Fluids through Valves, Fittings, and Pipe. New York: Crane Co. 1985.