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:
12 inches in cm gives 30.48 cm5 miles to km gives 8.04672 km2 lb as g gives 907.18474 g250 g -> kg gives 0.25 kg1.5 L → mL gives 1,500 mLconvert 6 feet into cm gives 182.88 cm1.8m→cm gives 180 cmMetric 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:
12 centimetres in inches gives 4.7244094488 inches3 decilitres in mL gives 300 mL2 tonnes in kg gives 2,000 kgA unit name on its own means one of that unit, which is a quick way to look up a conversion factor:
mile in km gives 1.609344 kmkg in lb gives 2.2046226218 lbConversions can be chained. Each step converts the answer so far, so the last unit wins:
2.5 m -> cm -> mm gives 2,500 mmUnits 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:
1 μm in nm gives 1,000 nm1 ångström in nm gives 0.1 nm20 ˚C in F gives 68 °F10 lb·ft in N·m gives 13.5581794833 N·m30 mi/gal in L/100km gives 7.840486119 L/100kmRounding 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:
5 km in miles gives 3.1068559612 mi5 km in miles to 2 dp gives 3.11 mi100 km/h in mph to 0 dp gives 62 mph1.7 m in ft to 1 dp gives 5.6 feet900 mm in inches to 1 dp gives 35.4 inches8 km to miles to 1 dp gives 5 miThe 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
intoonly works in theconvert … into …phrase. Elsewhere, useinorto. - Don’t put a number in front of the target unit.
2 m in feetconverts, but2 m in 3 feetdivides 2 m by 3 feet and shows2.1872265967 feet. - Symbols are case-sensitive.
MBis a megabyte andMbis a megabit, so100 Mb in MBis12.5 MB. pint,gal,quart,cupandfl ozare US measures. For British pints, gallons, quarts and fluid ounces, putUK,imporimperialin 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 kgor65 kg in pounds for the team.
1 UK pint in ml gives 568.26125 mL1 pint in ml gives 473.176473 mL3 bananas in kg gives Unsupported: unknown unit: bananasArithmetic 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 gworks, and the answer is shown in the larger of the two units. Addin …to choose a different one. - Multiplying and dividing combines units. A length times a length is an area, and
byworks 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.
1 kg + 500 g gives 1.5 kg500 mL + 2 L gives 2.5 L3 kg - 250 g in g gives 2,750 g2.5 kg * 4 gives 10 kg4 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 L2 kW * 3 hours gives 6 kWh10 km/h * 30 min gives 5 km120 km / 80 km/h gives 1.5 hours1 kg / 250 g gives 41 km > 900 m gives trueAnswers 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:
3 kW * 4 min gives 0.2 kWh600 kcal/hour * 45 min gives 450 kcal5000 mAh / 500 mA gives 10 hours64 kWh / 7.4 kW gives 8.6486486486 hours2.5 kg * 9.81 m/s² * 12 m gives 294.3 J1 / 0.02 s in Hz gives 50 HzAdding quantities of different kinds is an error:
2 km + 2 kg gives Error: incompatible unitsWhen 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:
2 kW * 3 hours in W*h gives 6,000 W·hour1 GB / (50 MB/s) gives 20 sPowers 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.
(3 m)^2 gives 9 m²sqrt(25 m^2) gives 5 mcbrt(27 m^3) gives 3 msqrt(100 m²/s²) gives 10 m/ssqrt(4 m^3) gives Error: unsupported multiplicative unitFunctions 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, m², sq m, square meters, square metres |
| Cubic metres | m^3, m³, 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) |
20 m² in sq ft to 0 dp gives 215 ft²100 sq ft in m² gives 9.290304 m²40 m * 25 m in hectares gives 0.1 ha1 km² in hectares gives 100 ha0.5 m³ in L gives 500 L1 ft³ in L gives 28.316846592 L1 g/cm³ in kg/m³ gives 1,000 kg/m³18 km/h + 5 m/s gives 10 m/sHeights and weights in feet, stones and pounds
Imperial heights and weights are often written in two parts. Varlig reads them as one quantity:
5'10" in cm gives 177.8 cm6'2" gives 6 feet 2 inches5 ft 10 in gives 5 feet 10 inches5 ft 10 in in cm gives 177.8 cm5 lb 4 oz gives 5 lb 4 oz7 lb 3 oz in kg to 2 dp gives 3.26 kg11 stone 4 pounds in kg to 1 dp gives 71.7 kg11 st 4 lb in kg to 1 dp gives 71.7 kg82 kg in stones and pounds gives 12 st 13 lb12.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:
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 m² 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:
2 uk gal in L gives 9.09218 L2 imp pt in ml gives 1,136.5225 mL1 UK fl oz in ml gives 28.4130625 mL1 imperial quart in L gives 1.1365225 L1 UK gallon in UK pints gives 8 UK pt2 US gal in L gives 7.570823568 LA 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:
180 cm in feet and inches gives 5 feet 10.8661417323 inches170 cm in feet and inches to 0 dp gives 5 feet 7 inches1.7 m in feet and inches to 1 dp gives 5 feet 6.9 inchesTemperature
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:
180 °C in °F gives 356 °F350 °F in °C to 0 dp gives 177 °C37 °C in °F gives 98.6 °F32 F in C gives 0 °C-40 C in F gives -40 °F20 °C in K gives 293.15 K20 degC in degF gives 68 °F180 degrees Celsius in Fahrenheit gives 356 °F37.5c in F gives 99.5 °Fgas mark 6 gives 200 °CYou 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:
18 °C + 5 °C gives 23 °C18 °C + 5 K gives 23 °CA 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 °Cis5 °C, and converting that to Fahrenheit gives41 °F, not a 9-degree change. - Multiplying by a plain number scales the number (
20 C * 2is40 °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 | m², ha, acres, sq ft |
| Volume | mL, L, m³, 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:
unit mug = 250 mL gives 250 mL6 mugs in L gives 1.5 L1 can = 330 mL gives 330 mL3 cans in mL gives 990 mLWrite 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:
unit mug = 250 mL gives 250 mL1.5 L in mugs gives 6 mugsA custom unit can be built from another custom unit, and the conversion factors multiply:
1 can = 330 mL gives 330 mL1 case = 24 cans gives 24 cans2 cases in L gives 15.84 LGeneric units
A generic unit has no physical size: it counts things, such as guests, slices or tickets.
Declare one with new unit:
slice = new unit gives slice3 slices + 5 slices gives 8 slices24 slices / 8 slices gives 3£36 / 24 slices gives £1.50Dividing 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.
2-3 kg gives 2 - 3 kg2-3 kg in lb gives 2 - 3 kgA 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:
10 km - 12 km gives -2 kmPutting 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:
# Raised bed for the vegetable patchbed length = 2.4 mbed width = 1.2 mbed depth = 30 cmbed length * bed width gives 2.88 m²soil = bed length * bed width * bed depth in L gives 864 L1 bag = 50 L gives 50 Lsoil in bags rounded up gives 18 bagsedging = 2 * (bed length + bed width) gives 7.2 m1 board = 1.8 m gives 1.8 medging in boards rounded up gives 4 boardsMixing 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.