-
Notifications
You must be signed in to change notification settings - Fork 154
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 fractions using superscripts and subscripts #166
Comments
+1 |
Can you describe more what you’re asking for? This project is primarily for turning text in to math. There is already support for the Unicode-defines fractions ( If you’re asking about more general features such as reducing fractions and keeping them as rational numbers instead of performing the division and turning them in to |
I hope to support the calculation of any fractions, thank you. |
How do propose representing these fractions in a string of text? |
Oh, are those superscript and subscript characters? |
Yes, can you support it? |
Perhaps... I already recognize superscript characters as exponents, such as @kerusan is this what you have in mind as well? |
The separate superscript is still expressed as an exponents. |
Yes, checking for the |
Some of the trickiness would be to correctly interpret |
Can this solution be used? |
... I completely forgot I'd implemented that already. Yes, that was basically how I was thinking of doing it (using implicit addition instead of implicit multiplication) |
So, are you going to support fractions calculation? |
Yeah, this will probably be ok. I'll warn you up-front however that there will be no way to get |
Is it possible to add a switch for the calculation result? If it is on, it is a fraction; if it is off, it is a Double, which is off by default. |
Not at this time. DDMathParser only supports calculations as Doubles. See #99. Supporting a different kind of evaluation number would require a very very very large and invasive change to the entire codebase. It's something I'd like to do eventually, but that sort of change is years down the road. This sort of "recognize fractions" bit is doable in days. |
How is this solution? |
For using in your own code, that seems reasonable at first glance. The problem with "using rational arithmetic throughout all calculations" as the answer suggests is that there is an entire domain of numbers that are not rational. As soon as you toss something like π in your string, you have to start dealing with mixing rational and irrational numbers as part of parsing and evaluation. This means that you're no longer doing evaluation of mathematical values, but are instead doing symbolic manipulations of them. Basically, you start dealing with numbers as a type that have a rational component, an irrational component, and an imaginary component, and then things get really weird as you try to define what it means to manipulate them. As much as I'd like DDMathParser to be a "complete" solution for parsing code and handling this sort of stuff, I'm just one guy doing this in my free time. 😁 |
Ok, I am converting the calculation results myself, huh. thank you very much. |
As the title.
Please check the attached examples, thank you.
The text was updated successfully, but these errors were encountered: