Skip to content
Varlig Guide
Varlig home

Units and conversions

Any number in a calc block can carry a unit: 250 g, 1.8 m, 20 °C, 100 Mbps. Once it has one, Varlig keeps track of it through the maths, so a length times a length is an area and a distance divided by a speed is a time. This page covers writing units, converting between them, doing arithmetic with them and defining your own. Reach for it whenever a calculation involves measurements: a recipe, a room, a journey, a download or a body weight.

Money has its own page, Money and currencies, and speeds, paces and fuel economy are covered in Rates, speed, pace, fuel and transfer time.

Attaching and converting units

Write the unit after the amount, with or without a space: 65 kg and 65kg are the same. To convert, add in, to, as, -> or and the unit you want, or write the phrase convert … into …. All of these do the same job:

calc
12 inches in cm gives 30.48 cm
5 miles to km gives 8.04672 km
2 lb as g gives 907.18474 g
250 g -> kg gives 0.25 kg
1.5 L mL gives 1,500 mL
convert 6 feet into cm gives 182.88 cm
1.8mcm gives 180 cm

Metric units can be spelled out the British or the American way, so centimetres, millilitres, litres and tonnes are as good as cm, mL, L and t:

calc
12 centimetres in inches gives 4.7244094488 inches
3 decilitres in mL gives 300 mL
2 tonnes in kg gives 2,000 kg

A unit name on its own means one of that unit, which is a quick way to look up a conversion factor:

calc
mile in km gives 1.609344 km
kg in lb gives 2.2046226218 lb

Conversions can be chained. Each step converts the answer so far, so the last unit wins:

calc
2.5 m -> cm -> mm gives 2,500 mm

Units copied from a datasheet or a web page work as they are. The Greek μ is read as micro, ˚C and as degrees Celsius, ångström as Å, and a compound unit keeps its meaning however its parts are joined, so lb·ft, lb-ft and ft·lb are all a torque and mi/gal is a fuel economy:

calc
1 μm in nm gives 1,000 nm
1 ångström in nm gives 0.1 nm
20 ˚C in F gives 68 °F
10 lb·ft in N·m gives 13.5581794833 N·m
30 mi/gal in L/100km gives 7.840486119 L/100km

Rounding a converted answer

Metric and imperial units rarely divide evenly, so conversions often produce long decimals. Add to N dp after the conversion to round the answer:

calc
5 km in miles gives 3.1068559612 mi
5 km in miles to 2 dp gives 3.11 mi
100 km/h in mph to 0 dp gives 62 mph
1.7 m in ft to 1 dp gives 5.6 feet
900 mm in inches to 1 dp gives 35.4 inches
8 km to miles to 1 dp gives 5 mi

The rounded answer stays in the unit you converted to, whether you write in miles or to miles. The full value is still used if you carry the answer into later lines. See Rounding for the other ways to round.

Conversion pitfalls

  • The word into only works in the convert … into … phrase. Elsewhere, use in or to.
  • Don’t put a number in front of the target unit. 2 m in feet converts, but 2 m in 3 feet divides 2 m by 3 feet and shows 2.1872265967 feet.
  • Symbols are case-sensitive. MB is a megabyte and Mb is a megabit, so 100 Mb in MB is 12.5 MB.
  • pint, gal, quart, cup and fl oz are US measures. For British pints, gallons, quarts and fluid ounces, put UK, imp or imperial in front. See UK and US measures.
  • A word that isn’t a unit shows an error when you convert it, so a typo can’t quietly give a wrong answer. Words around a calculation are still fine, as in 5 lbs of potatoes in kg or 65 kg in pounds for the team.
calc
1 UK pint in ml gives 568.26125 mL
1 pint in ml gives 473.176473 mL
3 bananas in kg gives Unsupported: unknown unit: bananas

Arithmetic with units

You can add, subtract, multiply, divide and compare quantities. The rules follow the physics:

  • Adding and subtracting needs the same kind of quantity (two masses, two lengths). The units don’t have to match: 1 kg + 500 g works, and the answer is shown in the larger of the two units. Add in … to choose a different one.
  • Multiplying and dividing combines units. A length times a length is an area, and by works between two lengths the way room sizes are written (4 m by 3 m). Power times time is energy, and a distance divided by a speed is a time. Units that appear on both sides of a division cancel out, leaving a plain number.
  • Comparing with >, < or == also needs the same kind of quantity, and converts before it compares.
calc
1 kg + 500 g gives 1.5 kg
500 mL + 2 L gives 2.5 L
3 kg - 250 g in g gives 2,750 g
2.5 kg * 4 gives 10 kg
4 m * 3 m gives 12 m²
4 m by 3 m gives 12 m²
3 m * 4 m * 2.5 m in L gives 30,000 L
2 kW * 3 hours gives 6 kWh
10 km/h * 30 min gives 5 km
120 km / 80 km/h gives 1.5 hours
1 kg / 250 g gives 4
1 km > 900 m gives true

Answers come out in the unit you’d use for them. Power over minutes or hours is energy in watt-hours, a rate of calories times a time is calories, a battery’s capacity over a current or a power lasts hours, and a force over a distance is work in joules:

calc
3 kW * 4 min gives 0.2 kWh
600 kcal/hour * 45 min gives 450 kcal
5000 mAh / 500 mA gives 10 hours
64 kWh / 7.4 kW gives 8.6486486486 hours
2.5 kg * 9.81 m/s² * 12 m gives 294.3 J
1 / 0.02 s in Hz gives 50 Hz

Adding quantities of different kinds is an error:

calc
2 km + 2 kg gives Error: incompatible units

When units don’t cancel, the answer keeps a compound unit. You can convert a compound unit by joining the target units with *, and it helps to put a rate in brackets when you divide by it:

calc
2 kW * 3 hours in W*h gives 6,000 W·hour
1 GB / (50 MB/s) gives 20 s

Powers and roots

Raising a quantity to a power raises its unit too. Square and cube roots work when the unit divides evenly: the square root of an area is a length, and the square root of a speed squared is a speed, but the square root of a volume has no sensible unit and is an error.

calc
(3 m)^2 gives 9 m²
sqrt(25 m^2) gives 5 m
cbrt(27 m^3) gives 3 m
sqrt(100 /) gives 10 m/s
sqrt(4 m^3) gives Error: unsupported multiplicative unit

Functions such as sin, ln and exp expect a plain number (or an angle, for the trigonometric functions), so sin(1 kg) is an error.

Squares, cubes and powers

There are several ways to write squared and cubed units. They all mean the same thing:

Meaning Accepted forms
Square metres m^2, m2, , sq m, square meters, square metres
Cubic metres m^3, , cu m, cubic meters, cubic metres
In a unit rate 9.81 m/s^2, 1 cm/s², 1 kg/m³ (powers work in denominators too)
calc
20 in sq ft to 0 dp gives 215 ft²
100 sq ft in gives 9.290304 m²
40 m * 25 m in hectares gives 0.1 ha
1 km² in hectares gives 100 ha
0.5 in L gives 500 L
1 ft³ in L gives 28.316846592 L
1 g/cm³ in kg/ gives 1,000 kg/m³
18 km/h + 5 m/s gives 10 m/s

Heights and weights in feet, stones and pounds

Imperial heights and weights are often written in two parts. Varlig reads them as one quantity:

calc
5'10" in cm gives 177.8 cm
6'2" gives 6 feet 2 inches
5 ft 10 in gives 5 feet 10 inches
5 ft 10 in in cm gives 177.8 cm
5 lb 4 oz gives 5 lb 4 oz
7 lb 3 oz in kg to 2 dp gives 3.26 kg
11 stone 4 pounds in kg to 1 dp gives 71.7 kg
11 st 4 lb in kg to 1 dp gives 71.7 kg
82 kg in stones and pounds gives 12 st 13 lb
12.5 st gives 12 st 7 lb

' means feet and " means inches, or write ft and in. In 5 ft 10 in in cm, the first in is the inches and the second converts the height. A number followed by in at the end of a line, or before an operator, is inches too, so screen = 55 in stores 55 inches and screen in cm gives 139.7 cm. A weight in stones shows stones and pounds; for a decimal, convert it with in stone.

Measurements in feet and inches multiply like any others, which is handy for a room measured with an imperial tape:

calc
14 ft by 12 ft gives 168 ft²
6 in * 6 in gives 36 in²
12'6" * 10'3" gives 128.125 ft²
12 ft 6 in by 10 ft 3 in gives 128.125 ft²
12'6" * 10'3" in to 1 dp gives 11.9 m²

UK and US measures

Gallons, quarts, pints and fluid ounces come in two sizes. On their own they’re the US measures, as in an American recipe. Put UK, imp or imperial in front for the British ones. Capitals don’t matter, so 2 UK Pints works as well as 2 uk pints:

calc
2 uk gal in L gives 9.09218 L
2 imp pt in ml gives 1,136.5225 mL
1 UK fl oz in ml gives 28.4130625 mL
1 imperial quart in L gives 1.1365225 L
1 UK gallon in UK pints gives 8 UK pt
2 US gal in L gives 7.570823568 L

A UK gallon is exactly 4.54609 litres, and holds 4 quarts, 8 pints or 160 fluid ounces. Before ton, UK and imperial mean the long ton of 1,016 kg, and US ton is the short ton. Cups and spoons have no UK size, so 2 UK cups shows an unknown unit rather than quietly giving a US answer. For a cup of 250 mL, write metric cup. Car fuel economy has a UK size too: UK mpg is miles per UK gallon (see Fuel economy).

Two-unit answers

To see an answer split across two units, as people usually say heights, weights and durations, convert to both units joined by and. Write the full plural unit names:

Target Example Answer
feet and inches 70 inches in feet and inches 5 feet 10 inches
pounds and ounces 2.5 lb as pounds and ounces 2 lb 8 oz
stones and pounds 82 kg in stones and pounds 12 st 13 lb
hours and minutes 135 minutes in hours and minutes 2 hours 15 min
minutes and seconds 200 seconds as minutes and seconds 3 min 20 s
days and hours 50 hours as days and hours 2 days 2 hours
weeks and days 50 days as weeks and days 7 weeks 1 day
months and days 45 days as months and days 1 month 15 days
months and weeks 100 days as months and weeks 3 months 1 week
years and months 500 days as years and months 1 year 4 months

Abbreviations don’t work here: 2.5 lb in lb and oz is an incompatible-units error, so write pounds and ounces.

Durations round to the nearest whole smaller unit, so 89.9 min in hours and minutes is 1 hour 30 min, and stones and pounds show whole pounds. Feet and inches, and pounds and ounces, keep any fraction, which a metric starting value usually leaves. Add to N dp to tidy it: the decimal places apply to the smaller unit, so you get a height you can read out:

calc
180 cm in feet and inches gives 5 feet 10.8661417323 inches
170 cm in feet and inches to 0 dp gives 5 feet 7 inches
1.7 m in feet and inches to 1 dp gives 5 feet 6.9 inches

Temperature

Celsius and Fahrenheit don’t start at zero, so converting between them involves an offset as well as a scale. Varlig handles that for you:

calc
180 °C in °F gives 356 °F
350 °F in °C to 0 dp gives 177 °C
37 °C in °F gives 98.6 °F
32 F in C gives 0 °C
-40 C in F gives -40 °F
20 °C in K gives 293.15 K
20 degC in degF gives 68 °F
180 degrees Celsius in Fahrenheit gives 356 °F
37.5c in F gives 99.5 °F
gas mark 6 gives 200 °C

You can write Celsius as C, °C, ºC, ˚C, , degC, celsius, degrees C, degrees Celsius or centigrade, Fahrenheit as F, °F, ºF, ˚F, , degF, fahrenheit, degrees F or degrees Fahrenheit, and kelvin as K or kelvin. C always means Celsius, except when you convert an electric charge, where in C gives coulombs. A lowercase c straight after a number can also mean cents, so Varlig reads the line. It’s Celsius in a conversion to a temperature (37.5c in F), next to another temperature, and on its own for a decimal, a negative number or 100 and over (180c). Next to money, before a rate, or for a whole number up to 99 on its own (99c), it’s cents. See Cents and pence. Oven gas marks follow the UK table; see Kitchen measures and oven settings.

Adding a change in temperature works when both amounts use the same scale. For a Celsius reading you can also add kelvin, because a change of 1 K is the same size as 1 °C:

calc
18 °C + 5 °C gives 23 °C
18 °C + 5 K gives 23 °C

A few things to watch for:

  • Keep both sides of a sum in the same scale. Adding a Fahrenheit amount to a Celsius reading doesn’t give a meaningful answer.
  • Subtracting two readings gives another reading, not a difference. 20 °C - 15 °C is 5 °C, and converting that to Fahrenheit gives 41 °F, not a 9-degree change.
  • Multiplying by a plain number scales the number (20 C * 2 is 40 °C), but multiplying two temperatures together, or a temperature by another unit, is refused.

Unit families

Varlig recognises a large catalogue of units. The main families are:

Family Examples
Length mm, cm, m, km, in, ft, yd, mi, NM, AU
Area , ha, acres, sq ft
Volume mL, L, , tsp, tbsp, cup, pint, UK pint, fl oz, UK fl oz, gal, UK gallon
Mass mg, g, kg, t, oz, lb, stone, long ton
Time s, min, hours, days, weeks, fortnights, months, years, decades
Speed km/h, mph, m/s, knots
Data MB, GB, GiB, Mbps, MB/s
Energy J, kJ, kcal, Wh, kWh, BTU, therm
Power W, kW, hp, bhp
Pressure Pa, kPa, bar, psi, atm, mmHg
Electricity V, A, mA, mAh, Ω, Hz

The complete list of symbols and spelled-out names, family by family, is in the unit catalogue. When you’re unsure of a spelling, the symbol is the safest choice.

Custom units

You can define a unit of your own in terms of an existing quantity, then use it like any other unit. Write unit or 1, then the name and what it equals. Both forms do the same job, so use whichever reads better in your note:

calc
unit mug = 250 mL gives 250 mL
6 mugs in L gives 1.5 L
1 can = 330 mL gives 330 mL
3 cans in mL gives 990 mL

Write the name in the singular or the plural, whichever reads naturally: 1 mug and 6 mugs both work.

A custom unit is also a conversion target, so you can ask how many of them something makes. That’s the quick way to count mugs from a jug or tiles for a wall:

calc
unit mug = 250 mL gives 250 mL
1.5 L in mugs gives 6 mugs

A custom unit can be built from another custom unit, and the conversion factors multiply:

calc
1 can = 330 mL gives 330 mL
1 case = 24 cans gives 24 cans
2 cases in L gives 15.84 L

Generic units

A generic unit has no physical size: it counts things, such as guests, slices or tickets. Declare one with new unit:

calc
slice = new unit gives slice
3 slices + 5 slices gives 8 slices
24 slices / 8 slices gives 3
£36 / 24 slices gives £1.50

Dividing money by a count gives the price of one. As with custom units, the singular and plural both work. Generic units can’t be converted to physical units.

Unit ranges

A line such as 2-3 kg is read as a range and shown as 2 - 3 kg. Ranges are for display only: they don’t convert, and they don’t take part in arithmetic.

calc
2-3 kg gives 2 - 3 kg
2-3 kg in lb gives 2 - 3 kg

A smaller number, a dash and a larger number with a unit is taken as a range, so 10 - 12 km is a range rather than minus 2 km. To subtract, put the unit on both numbers:

calc
10 km - 12 km gives -2 km

Putting it together

Here’s a note for building a raised bed in the garden. It works out how much soil to buy in 50-litre bags and how many 1.8 m edging boards go around the outside:

calc
# Raised bed for the vegetable patch
bed length = 2.4 m
bed width = 1.2 m
bed depth = 30 cm
bed length * bed width gives 2.88 m²
soil = bed length * bed width * bed depth in L gives 864 L
1 bag = 50 L gives 50 L
soil in bags rounded up gives 18 bags
edging = 2 * (bed length + bed width) gives 7.2 m
1 board = 1.8 m gives 1.8 m
edging in boards rounded up gives 4 boards

Mixing metres and centimetres is fine: the volume comes out in cubic metres and in L turns it into litres. Defining a bag and a board as units lets you convert straight into them, and rounded up gives whole ones, because you can’t buy part of a bag. Change bed depth to 45 cm and every answer below it updates.