Closed JoshuaCapel closed 5 years ago
I had a chance to play around with js-quantities and the issue exists there (https://github.com/gentooboontoo/js-quantities/issues/94). So that means this extension is just working as expected.
I've submitted a pull request fixing this to js-quantities, so we'll see if it's accepted. I'm reopening this to remind me to update the extension.
Now fixed in js-quantities v1.7.3, and I've updated this extension
I was playing around trying to fix an issue with the quantities extension and found some unusual behavior which I cannot fix. These issue occur even if you include my pull request earlier today (https://github.com/numbas/numbas-extension-quantities/pull/4).
The expression
1/quantity(1,"m")*quantity(1,"cm")
will become 1 cm/m instead of 0.01 as might be expected. You can also see this problem with the simpler commandquantity(1,"cm/m")
.More concerning is that the expression
quantity(1,"cm/m")*quantity(1,"")
becomes 100 cm^2/m^2, andquantity(1,"cm/m")*quantity(1,"")*quantity(1,"")
becomes 1000000 cm^4/m^4.These are actually technically correct (all being the same as 0.01), but it is not what I would have expected.
Adding in another unit prevents the second problem. For example
quantity(1,"kg*cm/m")*quantity(1,"")
is just 1 kg cm/m (so not simplified, but no strange powers appearing).Based on these observations it seem the problem is somehow related to unitless quantities.