calc icon indicating copy to clipboard operation
calc copied to clipboard

Numerator is assumed

Open Gusted opened this issue 3 years ago • 5 comments
trafficstars

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?

Gusted avatar Jan 28 '22 04:01 Gusted

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?

lcn2 avatar Jan 28 '22 11:01 lcn2

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.

Gusted avatar Jan 28 '22 11:01 Gusted

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.

lcn2 avatar Jan 28 '22 12:01 lcn2

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.

lcn2 avatar Jan 29 '22 12:01 lcn2

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?

Gusted avatar Jan 29 '22 18:01 Gusted

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.

lcn2 avatar Oct 04 '23 02:10 lcn2