If I calculate Qty("1m").div("1km") I get a unitless 0.001 as I expected.
But if I calculate (Qty("1").div("1km")).mul("m") I get 1 m/km. Which is actually correct, but I would have expected this to just be a unitless 0.001 as above.
Also if I calculate (Qty("1").div("1km")).mul("m").mul("") I get 0.001 m2/km2. Again this is technically the correct result, but not what I would have expected.
Is this an issue with js-quantities, or are my expectations wrong?
Thanks for reporting, your expectations are right and resulting units were inconsistent.
I have merged @christianp's PR #95 which has fixed the problem. I have just published a new release including it.
If I calculate
Qty("1m").div("1km")
I get a unitless 0.001 as I expected.But if I calculate
(Qty("1").div("1km")).mul("m")
I get 1 m/km. Which is actually correct, but I would have expected this to just be a unitless 0.001 as above.Also if I calculate
(Qty("1").div("1km")).mul("m").mul("")
I get 0.001 m2/km2. Again this is technically the correct result, but not what I would have expected.Is this an issue with js-quantities, or are my expectations wrong?