 # Units Calculator

## Introduction

 Convert Reciprocal   U.S. British   CGS: SI EMU ESU Gaussian

Defs:

The Fourmilab Units Calculator is based upon the GNU Units utility. It supports expressions in the “Convert” and “To” fields in the same syntax as described in the GNU Units manual. If the To field is left blank, the definition of the unit in the Convert field will be shown in terms of fundamental units. Entering “?” in the To field shows all standard units with the same dimensions as the expression in the Convert field. A total of 3460 linear units, 109 nonlinear units, and 109 prefixes are defined. The Units Calculator Expert page shows the most commonly used units and allows you to copy them to the Convert and To fields by clicking the unit.

You can define your own units or save intermediate results by prefixing the expression in the Convert field with a variable name beginning with a capital letter followed by letters and numbers (for example “Orbit”). Definitions are shown in the light blue box, and may be used in either the Convert or To fields. Definitions are lost when you reload the page, but may be copied from the definitions box and pasted back later, then reloaded with the “Load” button.

Almost all operations in Units Calculator are compatible with GNU Units. Extensions which apply only to Units Calculator are shown with a light grey background.

## Simple Conversions

Let's start with a very simple conversion. How many grams are in an avoirdupois pound? Each example in this document will show you what you enter in the “Convert” and “To” fields, then press the “Convert” button.

Convert To pound gram pound = 453.59237 gram

Press the “Convert” button in the box above and see the result, “pound = 453.59237 gram”, appear in the green results box in the form at the top.

Items separated by a space are multiplied. Hence you can convert any number of a unit to another unit simply by specifying the number (which has no units) in the “Convert” box.

Convert To 100 km miles 100 km = 62.137119 miles

For most units, you can specify either the full name or its usual abbreviation, and the usual forms of plurals are accepted (but ignored). In the example above you could have specified “kilometres” and “mile” and gotten the same result.

You can do arithmetic with dimensioned quantities using the usual operators of “+”, “-”, “*”, “/”, and “^” (for exponentiation). You will rarely need to use the “*” operator as multiplication is implied for items separated by spaces. You can also write fractions as two numbers separated by “|”, for example “7|8”. The dimensions (length, mass, time, etc.) of the “To” field must agree with those of the “Convert” field; if they don't, you will get a “conformability error” which shows the incompatible dimensions of the conflicting fields. The quantities on both sides of an addition or subtraction operator must also have the same dimensions; violating this constraint will result in an “Invalid sum or difference of non-conformable units” message. Parentheses may be used to force expressions to be evaluated in the desired order. This all sounds very complicated, but in practice it's pretty intuitive. Let's start by converting a speed in kilometres/hour into knots, where a knot is defined as one nautical mile per hour.

Convert To 10 kilometre/hour knot 10 kilometre/hour = 5.399568 knot

In this example I could have equally well entered “nauticalmile/hour” in the “To” field.

### Temperature

Conversions among different units of temperature are not simple linear factors because the zero point differs from system to system. For example, zero in the Kelvin scale is absolute zero, while in Celsius it it is the freezing point of water, and in the Fahrenheit scale it is something or other which works out to 255.37222° K. To convert absolute temperatures (as opposed to differences in temperatures), use the function-like expression “tempX(d)” where X is the letter for the system (“K” for Kelvin, “C” for Celsius, “F” for Fahrenheit, etc.) and d is the temperature in that system. To convert 61° Fahrenheit to Celsius, you'd use:

Convert To tempF(61) tempC tempF(61) = tempC(16.111111)

### Money

Currencies:

The Units Calculator treats money as a kind of dimension and arbitrarily uses the United States dollar (US\$ or USD) as the primitive unit. Exchange rates among different currencies are updated from freely available Internet resources once a day, most recently on , (and, like anything available for free on the Internet, you get what you pay for; before committing real money, it's wise to confirm rates from an authoritative source). The prices per troy ounce of gold, silver, and platinum are also available and updated daily. Let's compute the price, in Swiss Francs (CHF), of a cube of pure gold 10 centimetres on a side. The density of gold is one of those rare things Units Calculator does not know, so we look it up, 19.3 grams per cubic centimetre, from a handbook.

Convert To (10 cm)^3 (19.3 g/cm^3) goldprice CHF (10 cm)^3 (19.3 g/cm^3) goldprice = 865632.01 CHF

If you press the Convert button above, the value shown in the form at the top of the page will differ from that shown above, as it is evaluated based upon the price of gold and the exchange rate between the U.S. dollar and the Swiss Franc retrieved within the last day, not those at the time this page was composed.

## Scientific and Engineering Calculations

The ability to evaluate complex expressions involving units makes many computations easy to do, and the checking for compatibility of units guards against errors frequently made in scientific and engineering calculations. Let's solve the problem, “In an airplane flying at half the speed of sound, how long will it take (neglecting refuelling stops, etc.) in hours to fly around the Earth at the equator?”.

Convert To (2 pi earthradius) / (mach / 2) hour (2 pi earthradius) / (mach / 2) = 67.09413 hour

The GNU Units program, and hence Units Calculator, knows a wide variety of physical quantities such as, in this case, the equatorial radius of the planets and the conventional value of the speed of sound. A large number (but far from all) of widely used units are shown on the Units Calculator Expert page where you can fill them in the field just by clicking them.

For a more complex example, let's calculate the power emitted as gravitational radiation as the Earth orbits the Sun. This is given by the following equation, where G is the Newtonian gravitational constant, c is the speed of light, R is the radius of the orbit (which we'll assume here to be circular), and m₁ and m₂ are the masses of the two bodies. (You don't often see an equation in physics with an exponent greater than three, but this one has two fives and a four, and that's the fifth power of the speed of light in the denominator!) Since Units Calculator already “knows” all of the quantities which figure in this equation, we can immediately calculate as follows.

Convert To ((32 G^4)/(5 c^5 astronomicalunit^5)) ((sunmass earthmass)^2) (sunmass + earthmass) watt ((32 G^4)/(5 c^5 astronomicalunit^5)) ((sunmass earthmass)^2) (sunmass + earthmass) = 196.27068 watt

So, around 200 watts! The result of the last calculation is saved in the special variable “_”, so if you'd like that in horsepower, just ask.

Convert To _ horsepower (196.27068 watt) = 0.26320332 horsepower

You can, of course, use “_” in expressions just like any other unit name or number.

## Definitions of Units

Units Calculator works in a system of primitive units based upon the International System of Units (SI), extended to include concepts such as angles, solid angles, and money. To see the definition of any unit or expression in terms of these primitive units, enter the expression in the Convert field and leave the To field blank. Let's look up the definition of the Stefan-Boltzmann constant from thermodynamics, which relates the total energy radiated by a black body to its temperature.

Convert To stefanboltzmann Definition: pi^2 k^4 / 60 hbar^3 c^2 = 5.6703744e-08 kg / K^4 s^3

The left side of the definition is given in terms of physical constants such as the Boltzmann constant k, the reduced Planck constant , and the speed of light c, while the right side expresses the constant in the primitive units of kilograms, degrees Kelvin, and seconds.

## Finding Compatible Units

Given a unit or expression, you can find compatible units (those which are expressed in the same primitive units and hence can be added and subtracted) by entering the expression in the Convert field and “?” in the To field. Let's try joules per second and see what we get.

Convert To joule/second ? GAS_FLOW PRESSURE FLUID_FLOW POWER watt VA volt ampere W watt dBm horsepower 550 foot pound force / sec hp horsepower lusec liter micron Hg / s mbh 1e3 btu/hour poncelet 100 kg force m / s solarluminosity 382.8e24 W tonrefrigeration uston 144 btu / lb day watt J/s joule/second

The expression we have entered is of energy over time, or power, and hence we get a list of all units with those dimensions. In the list above I have elided many obscure units such as “donkeypower”. To see all of them in their wacky wonderfulness, click the Convert button to run the query in the form above.

## Defining and Using Variables

When performing a series of calculations, it's often handy to save quantities you've computed for use later in the calculation. Units Calculator (but not the GNU Units program) allows you to do this by prefixing a variable name, which must begin with an upper case letter, and an equal sign to an expression in the “Convert” field. For example, here we've defined a variable, Earthvol which we've computed to be the volume of the Earth.

Convert To Earthvol = spherevolume(earthradius) Earthvol = (1.083212e21 m^3)

Note that a light blue area has now appeared below the results box; this will show your variable definitions. Now you can use this variable in subsequent computations, for example to calculate the mass of the Earth, given its density of 5.514 grams per cubic centimetre. We'll save this as Earthmass.

Convert To Earthmass = Earthvol (5.514 g/cm^3) Earthmass = (5.972831e24 kg) Earthvol = (1.083212e21 m^3)

Now we can compute the escape velocity from the Earth.

Convert To sqrt((2 G Earthmass) / earthradius) km/sec sqrt((2 G Earthmass) / earthradius) = 11.186747 km/sec Earthmass = (5.972831e24 kg) Earthvol = (1.083212e21 m^3)

Usually, the definitions box will be shown only if you have made one or more definitions. You can control display of the box by the “Defs” drop-down button, setting it to “Auto” (show only if there are definitions), “Show” (show always), or “Hide” (never show). Definitions are not saved when you leave and reload the Units Calculator page. To save definitions, select and copy them to the clipboard, save in a local file, copy and paste them back into the definitions box (which you can display by setting “Defs” to Show), then press the “Load” button.

## Details

### Prefixes

Units Calculator recognises all twenty of the standard SI prefixes for powers of ten such as “kilo”, “giga”, “milli”, and “femto”. Prefixes may be concatenated with the unit they modify (“millimetre”) or used as a multiplicative factor (“mega parsec”). In addition the binary prefixes for powers of 1024 (“kibi”, “mebi”,…) may be used. Here we calculate the energy released by the annihilation of one tenth of a gram of antimatter.

Convert To 2 decigram c^2 kiloton tnt 2 decigram c^2 = 4.2961529 kiloton tnt

The energy released is calculated via Einstein's equation E = mc². The factor of two is because we must also include the energy of the normal matter annihilated by the antimatter. The unit “tnt” is defined as the customary value for the energy released by the explosion of a mass of the high explosive TNT. We could also have written “energy” instead of “c^2” as it is a synonym to simplify such calculations.

### English Customary Units

The English customary units (inches, pounds, gallons, etc.) are a mess. Not only are there endless ambiguities such as confusion between mass and force (pounds, slugs, poundals, anybody?) and between mass and volume (ounces), and curious conversion factors such as 5280 feet per mile, but the few territories which still use them can't even agree on their definitions. In the U.S. a pint is 16 fluid ounces, while in Britain it is 20 fluid ounces. And that fluid ounce…the U.S. fluid ounce is 29.57 millilitres (ml), while in Britain it's 28.41 ml. The same confusion afflicts units such as gallons, yards, and miles. A drop-down box lets you select the definitions used for these units. By default, the U.S. definitions are used; selecting “British” will use British definitions instead.

Convert To pint fluidounce U.S. British pint = 20 fluidounce

Prefixing the English unit with “br” or “us” (for example, “brgallon” or “usgallon”) will select the U.S. or British flavour of the unit regardless of the setting of the locale. This is wise to do when publishing calculations which may be used by others. Or, just don't use these silly units in the first place.

### CGS Electromagnetic Units

In most of science and engineering, SI units for electromagnetism are used. In some fields, and in older publications, you may encounter CGS (centimetre-gram-second) units, which have three flavours: electrostatic units (ESU), electromagnetic units (EMU), and Gaussian units. These definitions cause problems because they use, as fundamental units, square roots of the dimensions of mass and length, which are not supported by the GNU Units program. Units Calculator uses SI electromagnetic units by default. If you need to use one of the CGS unit systems, select it in the CGS drop-down menu. See the documentation for the GNU Units program for details on how these units are used and how to specify quantities in them.

### Wild and Woolly Units

Units Calculator supports a variety of units whose definition is socially constructed and cannot be defined from first principles. These include things like shoe sizes, wire gauges, grit sizes for abrasives, temperatures in “gas mark”, drill sizes, paper and envelope sizes, and other quaint curiosities. You can find them all in the units database. How many pieces of A4-size paper would it take to cover the entire surface of the Earth?

Convert To 4 pi earthradius^2 A4paper 4 pi earthradius^2 = 8.1780676e+15 A4paper

Lots!

### Built-in Functions

The standard mathematical functions acosh(), acos(), asinh(), asin(), atanh(), atan(), cosh(), cos(), exp(), ln(), log(), sinh(), sin(), sqrt(), tanh(), and tan() are provided. All of these functions accept pure numbers (without dimensions) as arguments, and the trigonometric functions cos(), sin(), and tan() accept, in addition, arguments with the dimension of angle. Inverse trigonometric functions return results with the dimension of angle.

You can compute the logarithm to an arbitrary base by specifying the base after the log function, for example log2(1000) for a log to the base 2.

The cuberoot() and sqrt() functions accept arguments with dimensions but will fail if no unit is defined with the requested root of the argument.

### Reciprocal Conversions

Some units are defined as exact multiples of others. In these cases, it may be that when you convert in one direction the conversion is obvious and succinct but in the other result in a factor with many decimal places. When using such conversions in a program, it may result in cleaner and easier to understand code to divide by the reciprocal of the conversion factor rather than multiply by the factor itself. If you check the “Reciprocal” box in the conversion form, you'll be shown both the direct (multiplicative) conversion and its reciprocal (to divide by). For example, if you want to convert from centimetres to inches, the direct conversion factor is 0.39370079… inch to the centimetre, but you can achieve the same conversion by dividing by the exact number 2.54.

Convert To cm inch Reciprocal cm = 0.39370079 inch cm = (1 / 2.54) inch