(if you want to participate in closed testing, send me an email at linus.internet@fastmail.se)
I got fed up with the GUIs of all unit converters on Android. To convert units you need a keyboard to type the units and a key to press when you want to convert. No clunky UIs. I don't want to go through menus to convert 6ft,2in to m.
So I started writing a unit converter. In the beginning it was a simple linear converter. Then one day someone pointed me to GNU Units and I got nerd-sniped into reading about dimension analysis. So what can it do?
expr in unit:
12h in s -> 43200s
and if we want to travel 9 lightyears in a year we would have to move at:
9ly in yr -> 9c
You can skip "in unit" and have Umits select a unit for you, but it will not always be great:
12h - 45min -> 40440s
While many people think of units like km/h or m/s like one units, they are compound units.
12km/h/12km/h -> 7,716049E-08 (T^-2)
compared to
12km/h/(12km/h) -> 1
if you know algebra, think of "in ng/l" as a division that doesn't cancel units,, and unquantified units as one of that unit. Something like this "2kg/1yr/(3m3/1s)/(1ng/1l).
Both , and . are treated as decimal separators.
when a calculation is successful, the result of that calculation is bound to a numbered variable $[num]. You can then reference that result in a latee calculation. If the calculation above was the first calculation of the session, it would have been bound to $0. Then we can do
$0 in ng/M3 -> 21125,39 ng/m3
Sometimes you can get really weird answers even for queries you thought were sane. If you forget the /h at the end, of "(31l/m2)/1min in mm/h" the reply is instead in Bequerel. If we reduce the above, it becomes (0,0031m3/1m2)/60s in mm/h, which becomes 0,0031m/60s. "in" is just a fancy divider, so specifying this in mm means the 0,0031m loses its unit, and left is 3.1/60s which becomes 0.05[...]/s which is read as N per second, i.e. Bequerel (or if unit definitions in Units worked differently, Herz).
In the world of unit conversion and physics, a dimension is the fundamental physical nature of a quantity, regardless of the units used to measure it.
A good example is length. Meter, inch, furlong and lightyear each describe the same thing. Every one of those units can be described in terms of the other.
Like in algebra, if we have A² and B, we can multiply them and divide them, but we cannot add or subtract. 15m + 15ft is no problem because they reduce to the same thing. 15m + 10s does not work. 15m/10s however is the same as 5,4km/h. You cannot do 10kg + 10m³, but you can get the density by doing 1kg/m³.
6000m + 50ft in mi -> 3,737697 mi
65mi in 12mi/h -> 19500s
oh
65mi/(12mi/h) in h,min -> 5h 25min
It also saves the previous results as $[nr]. The example above is $2 in our session.
$2 in d -> 0,2256944 d
Aerodynamic drag of a car moving at 120km/h
Air Density: 1.225 kg/m^3
Velocity: 120 km/h
Drag Coefficient: 0.28
Frontal Area: 2.2 m^2
0.5 * 1.225 kg / m3 * (120 km / h)^2 * 0.28 * 2.2 m2 in N -> 419.2222 N
Dilution when adding 2kg of a substance per year to a stream of 3m3/s:
(2kg/yr)/(3m3/s) in ng/l -> 21.12539ng/l
If I have 1kg of Cobolt60, and I stand 4m away, how long until I reach ld50/30 (50 risk of death in 30 days)
The ld50/30 dose is 5Sv
Cobalt60 has a decay of 41.9PBq
The gamma constant is 0.351mSv * m2/GBq * h)
5 Sv * (4 m)^2 / (0.351 mSv * m2 / (GBq * h) * 4.19e7 GBq) in s -> 19.58264 s
If you start by writing just "in [unit]" the previous result is inserted at the start. Continued from above:
in min -> 0.3263773 min
Length (m), mass(kg), time(s), current(A), temperature(K), bits(b), mol (mol) and luminous intensity(cd).
All other units are derived from those.
All SI prefixes (?) are supported. The kilometer gets the symbol km. The petameter Pm etc. This means the kilofoot is supported (kft).
any unit ending in a whole number is a shorthand for ^. "1m3" is the same as "1m^3". If you want negative powers or fractions you need to use the full syntax. "10^-3" or "10^0,5".
I don't want to write a pretty list. Here is the source code. The m2 and m3 is defined to print better results for when units are not provided
("min", "60 s")
("h", "60 min"); ("hr", "1 h")
("d", "24 h"); ("day", "1 d")
("wk", "7 d"); ("week", "1 wk")
("yr", "31557600 s"); ("year", "1 yr") //Julian year!
// Length
("in", "0.0254 m")
("ft", "12 in")
("yd", "3 ft")
("mi", "5280 ft")
("nmi", "1852 m")
("au", "149597870700 m")
("ly", "c * 1 yr")
("pc", "3.085677581491367e16 m")
("m2", "m^2")
("m3", "m^3")
// Volume
("l", "0.001 m3")
("gal", "3.78541 l")
("qt", "0.25 gal")
("pt", "0.5 qt")
("fl_oz", "0.0625 pt")
// area
("ha", "10000 m2")
("are", "100m2")
("acre", "4046.8 m2")
("g", "0.001 kg")
("lb", "0.453592 kg")
("oz", "0.0625 lb")
("ton", "1000 kg")
("u", "1.66053906660e-27 kg")
("amu", "1 u")
("N", "kg * m / s^2")
("lbf", "1 lb * gn")
("Pa", "N / m^2")
("bar", "100000 Pa")
("atm", "101325 Pa")
("psi", "lbf / in2")
("J", "N * m")
("Nm", "J")
("W", "J / s")
("Wh", "W * h")
("hp", "745.6998715822702 W")
("cal", "4.184 J")
("BTU", "1055.05585262 J")
("eV", "1.602176634e-19 J")
("C", "A * s")
("V", "W / A")
("ohm", "V / A")
("F", "C / V")
("H", "V * s / A")
("Wb", "V * s")
("tesla", "Wb / m2")
("T_tesla", "1 tesla")
// IT
("B", "8 b")
// Photometry
("sr", "1") // Steradian (solid angle)
("lm", "cd * sr") // Lumen (luminous flux)
("lx", "lm / m2") // Lux (illuminance)
// Constants
("planck", "6.62607015e-34 J * s")
("hbar", "planck / (2 * pi)")
// Radioactivity
("Sv", "J / kg")
("Gy", "J / kg")
("rem", "0.01 Sv")
("rad_dose", "0.01 Gy")
("Bq", "1 / s")
("Ci", "3.7e10 Bq")
("R", "2.58e-4 C / kg")
// Angles & Rotation (Dimensionless)
("rad", "1")
("deg", "pi / 180")
("rev", "2 * pi")
("rpm", "rev / min")
// Dimensionless ratios
("%", "0.01")
//Parts per ...
("ppm", "1e-6")
("ppb", "1e-9")
("ppt", "1e-12")Also supported are degC and degF together with standard gravity (gn), the speed of light (c) and pi (pi).
These are not units per se, but macros. The common way we think about dB is dB sound pressure level (dBSPL), which is defined like this:
dBSPL[pressure] = 20 * log10({pressure} / 20uPa)
The other dB versions are defined as:
// Power (Reference: 1 Watt and 1 milliWatt)
dBW(power) = 10 * log10({power} / 1W) * 1 dB
dBm(power) = 10 * log10({power} / 1mW) * 1 dB
// Voltage (Reference: 1 Volt)
dBV[voltage] = 20 * log10({voltage} / 1V) * 1dB
Where dB is a dimensionless unit.
This means we have to treat them specially: we cannot just say 5W in dBW.
This is true for all logarithmic units, like Niepers, decade, pH and stellar magnitude.
Umits specifies the following functions:
log(n, value) = does a logn on value
log(value), log10(value)= one-argument versions of the function above. They do log10
ln(value) is the same a log(e, value)
sin, cos, tan = you know these
sqrt = square root.
a light mode
Small toolbar to help with parentheses and finding macros and entities.
User units, entities and macros. the user should be able to define their own things. If I need a lot of info about puff pastry in my calculations I should be able to define that, together with macros to abstract away the tough calculations.

