calc
calc copied to clipboard
Numerator is assumed
When doing a division(e.g. 1/2), the provided numerator is used.
However when you don't specify the numerator(e.g. /2), calc assumes the numerator is 1 and process it with that value. I couldn't find documentation if this is a intended change or not as all calculators I've used trowed a error on such expression. Is this intended, or is this a bug?
This is an odd behavior / feature. We didn't know that calc assumed a numerator of 1.
This looks line an undocumented "feature". It does not look like it harms anything that we can think of.
Perhaps your issue should be closed with a "well noticed" comment? What do you think?
I'm not sure, I think it should throw a error as I'd found this error by accident when I made a typo and forgot to add a numerator the a division, which yielded in a weird result. Cross-checking on another calculator it gave me why it was yielding a weird result, the division didn't had a numerator.
Someone could have the same mistake by forgetting a numerator, then calc stills evaluates it and gives a "incorrect" result as someone could meant to not have the 1 as a numerator.
We are not use if this is a bug or a feature. :-)
We are also not sure that there might be code out there that assumes /2 would work.
Hummm .. have to think about this.
More comments and perhaps even a proposed patch as a pull request are welcome.
We guess this comes down to a "is it a bug or feature?" question, @Gusted.
If this is a "feature" of the calc parser, one might also suggest this might be a feature that one might not want to encourage people using. On the the other hand we cannot think of a harm that such a "feature" causes.
We might document the "/2" feature for now AND indicate that it should not be used as it might be disallowed in the future.
What do you think of that approach?
Alternately if "/2" is a bug, then the parser would need to carefully be modified to disallow it.
Hmm, I think it's a nice feature, but one that shouldn't exist really. I'd like the approach of documenting the /2 feature with the indication that it will be disallowed/removed in the future. Alternatively to raise some awareness to this, is it possible to log a "WARNING" that when this is used, that it shouldn't be used?
This issue will be addressed in calc v3: see issue #103. We are closing this issue do that any further discussion may occur in issue #103.