Using Units in Calcumber

Calcumber supports calculations with units and automatic unit conversion. All examples given are interactive. Change the target units in below example and see how the conversion result changes.

Adding compatible units:  
5 m + 30 cm + 5 inch 5.427 m
   
Average speed during a car trip:  
57 km / 40 min 1.425 km/min
ans to km/h 85.5 km/h
ans to mph 53.127237 mph
   
Right-angled triangle:  
a = 3 m 3 m
b = 4 m 4 m
c = sqrt(a^2 + b^2) 5 m
   
Water flow rate:  
20 l/min to m3/h 1.2 m3/h

See: list of defined units

Documentation TODO: preferred units, conversion of absolute temperature scale.

Rules for Entering Units

In Calcumber, spaces are significant when working with units. Use spaces to separate numbers, units, and operators, but not within a unit expression.

Use space between number and unit:

5 m   # unit meter 5 m
5m    # multiplier milli 0.005

End unit expressions with a space:

5 m^2     # square metres 5 m2
5 m ^2    # square the value 5 m 25 m2
   
1 m+1 m    # space missing  
1 m + 1 m  # space between 'm' and '+' 2 m
(1 m)^2    # bracket after unit is fine 1 m2

Don't use space within unit expressions:

You defined in some preceeding calculation:  
Mass: m = 5 kg 5 kg
   
Now you calculate torque:  
correct: T = 18 N*m    # unit Newton metre (=J) 18 J
wrong:   T = 18 N * m  # multiply by variable m 90 N*kg

Unit Conversion

For unit conversion, use the keyword to or in.
Use to base or in base to convert to base units.

50 mph to km/h 80.4672 km/h
3 gal in L 11.356235 L
   
Miles per gallon to L/100 km:  
1 / 23 mi/gal 0.043478261 gal/mi
ans to cl/km     # = L/100 km 10.226721 cl/km
   
Weight of US Letter Paper:  
8.5 inch * 11 inch * 80 g/m2 to g 4.8257968 g
   
To base units:  
1 mph to base 0.44704 m/s
10 N to base 10 kg*m/s2

Partial conversion: If the requested target unit does not match the dimension of the input quantity, Calcumber performs a partial conversion and preserves the remaining dimensions. This can reveal interesting physical relationships:

1 W to s    # Power is energy per unit time 1 J/s
1 L to cm   # Volume is length cubed 1000 cm3
1 Pa to J   # Pressure is energy per unit volume 1 J/m3
1 mm to L   # Rainfall depth and volume 1 L/m2

Using Undefined Units

Units do not need to be predefined. Undefined units can still be used in calculations and may either cancel out or remain in the result.

Using undefined unit 'person':  
water_consumption = 150 L/person/day * 8000 person to m3/h 50 m3/h
   
Using undefined unit 'EUR':  
energy_bill = 0.29 EUR/kWh * 7600 kWh/year 2204 EUR/year

Multiplier Prefixes

Many units support multiplier prefixes. Example using Joule:

1 aJ  to J  # atto 1e-18 J
1 fJ  to J  # femto 1e-15 J
1 pJ  to J  # pico 1e-12 J
1 nJ  to J  # nano 1e-9 J
1 uJ  to J  # micro 1e-6 J
1 µJ  to J  # micro 1e-6 J
1 mJ  to J  # milli 0.001 J
1 cJ  to J  # centi 0.01 J
1 dJ  to J  # deci 0.1 J
1 J 1 J
1 DJ  to J  # deka 10 J
1 hJ  to J  # hecto 100 J
1 kJ  to J  # kilo 1000 J
1 MJ  to J  # mega 1e6 J
1 GJ  to J  # giga 1e9 J
1 TJ  to J  # tera 1e12 J
1 PJ  to J  # peta 1e15 J
1 EJ  to J  # exa 1e18 J

List of Units

SI Units

Base Units:

1 m   # length, meter 1 m
1 s   # time, second 1 s
1 kg  # mass, kilogram 1 kg
1 A   # electrical current, Ampère 1 A
1 K   # temperature, Kelvin 1 K
1 mol # amount of substance, mole 1 mol
1 cd  # luminous intensity, candela 1 cd

Derived Units:

1 g   to kg       # gram 0.001 kg
1 Hz  to 1/s      # Hertz 1 1/s
1 N   to kg*m/s^2 # Newton 1 kg*m/s2
1 Pa  to N/m2     # Pascal 1 N/m2
1 J   to N*m      # Joule 1 N*m
1 W   to J/s      # Watt 1 J/s
1 C   to A*s      # Coulomb 1 A*s
1 V   to J/C      # Volt 1 J/C
1 Ohm to V/A      # Ohm 1 V/A
1 S   to 1/Ohm    # Siemens 1 1/Ohm
1 F   to C/V      # Farad 1 C/V
1 Wb  to V*s      # Weber 1 V*s
1 T   to V*s/m2   # Tesla 1 V*s/m2
1 H   to V*s/A    # Henry 1 V*s/A
1 lm  to cd*sr    # lumen 1 cd*sr
1 lx  to lm/m2    # lux 1 lm/m2
1 Bq  to 1/s      # Becquerel 1 1/s
1 Gy  to J/kg     # Gray 1 J/kg
1 Sv  to J/kg     # Sievert 1 J/kg
1 kat to mol/s    # katal 1 mol/s

Angular and Scalar Units

Angular units:

1 rad    to 1        # radian 1
180 deg  to 1        # degree 3.14159
180°     to 1        # ° unit works without space 3.14159
1 deg    to arcmin 60 arcmin
1 arcmin to arcsec 60 arcsec
1 sr   to 1          # steradian 1

Scalar units:

1 %    to 1  # percent 0.01
50%    to 1  # % unit works without space 0.5
1 ppm  to 1  # parts per million 1e-6
   
Calculating a percent value:  
4.8 / 6.7 in % 71.6418 %
   
Thermal Expansion:  
CTE = 45 ppm/K 45 ppm/K
l = 1.5 m 1.5 m
ΔT = 70 K 70 K
Δl = CTE * l * ΔT to mm 4.725 mm
l + Δl 1.50473 m

Length

1 inch to m        # inch 0.0254 m
1 in               # 'in' is keyword (alias for to)  
1 mil  to inch     # thousandth of inch 0.001 inch
1 ft   to inch     # foot 12 inch
1 mi   to ft       # mile 5280 ft
1 yd to ft         # yard 3 ft
1 au   to m        # astronomical unit 1.4959787e11 m
1 dioptre in 1/m   # dioptre 1 1/m

Area

1 are to m2  # are 100 m2
1 ac to ft2  # acre 43560 ft2
1 ha to m2   # hectare 10000 m2

Volume

1 L to dm3     # litre 1 dm3
1 l to dm3     # litre 1 dm3
1 gal to L     # US gallon 3.7854118 L
1 gal to qt    # US quart 4 qt
1 qt to pt     # US pint 2 pt
1 gal to floz  # US fluid ounce 128 floz
1 floz to tbsp # tablespoon 2 tbsp
1 floz to tsp  # teaspoon 6 tsp
1 cup to L     # Approx. metric cup 0.24 L

Time

1 min to  s 60 s
1 h to min 60 min
1 d to h 24 h
1 week to d 7 d
1 month to d 30.4375 d
1 year to d 365.25 d
1 year to month 12 month

Aliases: hour, hours, day, days, weeks, a, years, months

Speed

1 mph to km/h   # miles per hour 1.609344 km/h
1 fps to m/s   # foot per second 0.3048 m/s
1 knot to km/h  # nautical mile per hour 1.852 km/h

Mass

1 t    to kg     # ton 1000 kg
1 lb   to kg     # pound (avoirdupois) 0.45359237 kg
1 lb   to oz     # ounce 16 oz
1 st   to lb     # stone 14 lb
1 ton_us to lb   # US ton 2000 lb
1 ton_uk to lb   # UK long ton 2240 lb
1 Da   to kg     # Dalton 1.6605391e-27 kg

Energy:

1 eV to J   # electronvolt 1.6021764e-19 J
1 Wh to J   # Watt hour 3600 J
1 BTU to J  # British thermal unit 1055.0559 J
1 cal to J  # calorie 4.184 J
1 Cal to J  # Used on food labels = 1 kcal 4184 J

Temperature and Temperature Conversion

The following temperature units are defined in Calcumber:

K Kelvin. Base unit for all temperatures.
°C or degC Degree Celsius
°F or degF Degree Fahrenheit
°Ra or degRa Degree Rankine

By default, all temperature values are interpreted as temperature differences. Therefore, converting °C to Kelvin will not add 273.15 K. This behavior prevents interpretation problems in many calculations as shown in the example below:

Expression Result
Mass:           m  = 100 kg 100 kg
Temp. increase: ΔT = 40 °C 40 °C
Spec. heat:     cp = 4182 J/(kg*K) 4182 J/(kg*K)
   
Energy needed:  
m * ΔT * cp  to kWh 4.6466667 kWh

Heating up 100 kg of water by 40°C needs 4.6 kWh. If Calcumber would convert 40°C to 313 K, the result would be 36.4 kWh, which would be the value for heating it up from 0 K to 313 K.

For converting actual temperature values between the scales, use the defined conversion functions as below:

Expression Result
Conversion of temperature differences:  
10 °C  to K 10 K
10 °F  to K 5.5555556 K
   
Conversion of temperature values:  
to_K(10 °C) 283.15 K
to_K(10 °F) 260.92778 K
to_degF(0 °C) 32 °F
to_degC(0 °F) -17.777778 °C
to_degRa(1000 °C) 2291.67 °Ra

Force and Pressure

Force:

1 lbf to N   # pound-force 4.4482216 N

Pressure:

1 bar to Pa 100000 Pa
1 psi to bar  # pounds per square inch 0.068947573 bar
1 atm to bar  # standard atmosphere 1.01325 bar