-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support mixed fractions in parser #731
Comments
Whilst I agree about the comment about implied multiplication, the reality is that is that "8 3/4" meaning 8+3/4 has been around as long as the concept of implicit multiplication. This is a special case that the parser should handle, as the actual number is 8 3/4 or 8.75. In other words, 8.75 wouldn't cause an issue, but 8 3/4 would. But 8.75 == 8 3/4, so this is a problem in the parser. 8.75 (2+3) should be the same as 8 3/4 (2+3) . I don't think anyone would argue that this is 8_3/4_(2+3) BTW, the sign between the whole and the fraction is the sign of the whole number. |
@FSMaxB |
ping @josdejong |
So far we've been very carefully with allowing implicit operations: they can easily lead to ambiguity and misinterpretations. We can certainly rethink earlier decisions. To get a clear picture on the implications of supporting this fraction notation
Whilst this notation could lead to weird situations, I still think it would be a really convenient one to support. For example the built in calculator of Google does support it too. |
@evykassirer do you have an opinion in this regard? |
Anything that doesn't break existing parsing and supports new forms of input (that people will use) is a great feature in my opinion. I don't think that Socratic needs this kind of parsing currently, but maybe it would in the future :) |
Thanks for your input Evy, clear. |
Marking as a feature and changed issue title. |
I've recently done some changes in this regard, see #2370. Closing this issue. Please open a new issue if there are still related issues. |
I'm using mathjs to evaluate free form text from a user. Actually input co-ordinates for a CNC. I am doing basic processing to clean up the input. However, mathjs fails on an input which is a whole number and fraction, which is common when dealing with inches and fractions. This can be tested using the "demo" on the front page of mathjs.org.
So:
-8 3/4 - causes and error
-8 - 3/4 - prints -8.75
8 + 3/4 - prints 8.75
isNumeric(-8 3/4) returns false as well
etc
As I am new to mathjs I apologise if this has been addressed before. This seems to be a defect in the parser as it is expecting an operation between the "8" and "3/4" rather than realising that this is a whole number and fraction, which to me should be a valid number.
The text was updated successfully, but these errors were encountered: