New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing numbers with ending dot #711

Closed
trojanowski opened this Issue Sep 13, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@trojanowski

trojanowski commented Sep 13, 2016

I've noticed that after resolving #707 it's not possible to parse expressions like 1. / 2. anymore. Would be possible to add a config option to bring back the previous behavior? That expression is correct in JavaScript, Python, Excel and many calculators. I'm using mathjs parser eg. for calculating expressions with significant numbers. There is an important difference between 1000 and 1000. in that case.

@ThomasBrierley

This comment has been minimized.

Contributor

ThomasBrierley commented Sep 13, 2016

I think the intention of the fix for #707 was only to change the behaviour of the ambiguous case (where there are no space delimiters). This looks like another bug because clearly the dot belongs to the operand.

@josdejong

This comment has been minimized.

Owner

josdejong commented Sep 13, 2016

In #707 I simply removed support for a dot at the end of a number. Sorry to hear that this notation was actually used, I have never seen this in practice (unlike short notations like .2 or numbers entered as 2.0 to enforce creating a floating point instead of an integer).

The reason for the fix was ambiguity, since math.js has element wise operators .*, ./, and .^. Thinking about it, it should be possible to still support both, the parser should do a look ahead when parsing a digit in a number. I will have a look into it soon.

Please note that a difference between 1000 and 1000. is artificial: they are both parsed as a number with the exact same value. It can have meaning though for the people reading the expression.

@trojanowski

This comment has been minimized.

trojanowski commented Sep 14, 2016

Thinking about it, it should be possible to still support both, the parser should do a look ahead when parsing a digit in a number. I will have a look into it soon.

Thank you.

Please note that a difference between 1000 and 1000. is artificial: they are both parsed as a number with the exact same value. It can have meaning though for the people reading the expression.

Yes. In the case I mentioned before (calculating significant numbers - working version) I'm using mathjs.parse to build an expression tree and calculate it by myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment