Open roromo opened 2 years ago
Fixed in libqalculate (https://github.com/Qalculate/libqalculate/commit/4881893a95f62b2eea4e31b7983d0e0b0ca6b5c1).
The expression can however be considered somewhat ambiguous, since it will be interpreted differently in "conventional" mode.
My surprise was to see the parsed expression, where something like 5V is seen as "5 x volt". I was thinking that units are not something you multiply with a numerical expression, and the ambiguity dialog that was referring strictly (in my view) to number multiplications was just a warning that might have been badly triggered in this case.
But I see now your added help string where it shows that the meaning changes if you have or don't have a space between the numerical expression and the unit name. So yeah, I see now that it's ambiguous, just that it's not a case about "implicit multiplication" as referred to by the dialog, but it's about how units are associated to numbers or expressions.
I think I understand now that the parsing engine handles units associations to numbers or expressions the same way it handles operator associations, so that's why the same dialog with the same warning message is triggered. It was not making sense to me before because I did not know this, now it does.
I may not be the only one that would use Qalculate for the first time and would be surprised by having this dialog pop up in case of units though. Maybe it would help to also add "or unit names" to the warning message, besides the units example (which really helps!) and have something like this "Please select interpretation of expressions with implicit multiplication or unit names" ? And in that case the dialog may be shown in this case without confusing the user (or at least without confusing someone like me :) )
PS: Please feel free to close this issue now, or after making any other changes you see suitable, btw.
I will try to make the dialog more informative.
Even if the relation between quantity and unit is not considered as multiplication (although, formally, "the space between the number and the unit is regarded as a multiplication sign", according to BIPM), there are potential ambiguities when determining what exactly constitutes the quantity (number and unit), e.g. 1/2 m
(half a meter or 0.5 Hz), x/2 m
(is the quantity 2 or x/2), 1 m/2 m*s
(is the unit of the denominator m or m⋅s), etc. There are unfortunately no general standard for how to interpret expressions with multiplication division on a single line regardless if it involves units or variables.
Perhaps I should change the behaviour to use space, as recommended by BIPM, instead of a multiplication sign between number and unit, everywhere. (If so I should probably also replace multiplication x with dot between units.)
Starting Qalculate for the first time (installed using the 64 bit Windows installer) and using the default settings, with "Parsing mode = Adaptive", type this expression in Qalculate (GUI version, either Qt and GTK):
(5V-1.4V)/32ohm
On pressing Enter, a "This expression is ambiguous" dialog pops up, which doesn't make sense as the expression is not ambiguous at all.
The dialog does not pop up afterwards, it's just a one time occurrence, but it pops for an expression which is not ambiguous.