Automatic cancelation of derived units #2658
-
When I multiply two quantities, I would expect that any unambiguous cancellations of derived units would be applied automatically, however this example using mathjs@7.2.0 returns
If there are performance reasons to defer this type of automatic simplification, perhaps a method to manually trigger would be useful (and apologies if it already exists and I missed it). The I noticed the |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
In most cases the units will be simplified. @ericman314 do you have an idea why |
Beta Was this translation helpful? Give feedback.
-
I'm not sure. If anything, I would think it should return Units are not actually simplified until they are formatted for output; this does improve the performance if you have lots of calculations in a row, and output one answer at the end. But this also means Because of these problems, I've been working on a complete overhaul of the units for a while now, and when that is ready it should address issues like this. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your feedback. Can we already try this example out in UnitMath? :) |
Beta Was this translation helpful? Give feedback.
-
Yes--I believe it should be working there. |
Beta Was this translation helpful? Give feedback.
-
That is the correct answer here since |
Beta Was this translation helpful? Give feedback.
I'm not sure. If anything, I would think it should return
W
since that is even simpler thanJ / s
. It doesn't really "know" that it should cancel the m's, it just looks at the entire unit to see if there is a single unit (like W) that fits.Units are not actually simplified until they are formatted for output; this does improve the performance if you have lots of calculations in a row, and output one answer at the end. But this also means
toString
has side effects--ouch!Because of these problems, I've been working on a complete overhaul of the units for a while now, and when that is ready it should address issues like this.