-
Notifications
You must be signed in to change notification settings - Fork 157
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
Fraction Calculation #90
Comments
Hi, Thx for your feedback. What do you mean to calculate fractions? You can write 3/4 or 5/2 - mXparser will perform division. But remember - the final number is always returned as double. Best regards |
I will introduce new method toFraction(double number) to convert double to fraction on request :-) |
Thanks! When will v4.2 should be coming? |
I do not plan to release v.4.2 any soon. But the code for will be on github in a few days. Which platform do you use? Java//.net? |
The only condition is that you will give a star to the repo :-) |
Hello, O am using Java. Also, what do you mean I will give a start to the repo |
:-) Star on github, that you like mXparser :-) I just misspelled "star" as "start" - sorry. |
So I will build new jar just for you, containing this new feature. This feature will enable to convert the final result, which is double, to two integer numbers (numerator and denominator) or to one string "numerator/denominator". The method will be in mXparser calls. Possible usage will be s will be "15/14" |
Cool! I am just thinking what if I have a mixed fraction (you can learn more about what I mean on Google), what should I do. Also, this custom jar, won't change how division works. So 3/2 * 5/7 result would be 1.0714285715 and if I use toFraction(e.calculate) then it would return fraction, right? Ps: I am working on a PhotoMath alternative & I am thinking about making mXparser - a core calculator for app. So I need fractions and etc. support. |
Currently this cannot be supported, but I will think on that. |
This could work as that: 5_2_3 But this is much bigger change as requires grammar modification. |
Let me know what you can make, I usually check GitHub Notifications every 4-6h, thanks! |
Decided - it will be possible to use number literals in fraction form directly in expression. Expample Expression e = new Expression("2_3 + 2_1_2"); will evaluate to 3,16666666666667, and then using mXparser.tofraction( double ) it will be possible to convert it to a fraction again. Bes regards |
Oh ok! Thanks for the info. |
So it is done :-) Fractions number literals support Double to fraction conversion
I recommend to start testing on this ones
:-) |
Thank you so much, regards. |
Please let me know your views on implemented changes. It required a lot of work :-) You should have jar on your email. |
Aha - i decided to represent fraction as array of double, I did not wanted to introduce new Fraction class as majority of use case will be on strings. normal fraction - double[3] Mixed fraction - double[4] Bes regards |
Great idea, amazing! |
Please let me know when you test it. |
Did you use double arrays? |
Yes, double has much bigger range. Long is limited to 2^64, double is something 10^307. All the mXparser is based on double. The method toFractionString formats double to nice integer, but allowing huge range. In this double array always integer is stored (not the int type, the value without decimals). |
Did you manage to test it? |
Hello, it works! Currently I am using my own custom instance of SympyGamma on App Engine, but this will be used for a normal calculator in my app. |
Released - check nuget or maven :-) |
Hello, I am amazed by how powerful and simple this library is! I am currently stuck by this question, How to calculate fractions? Regards.
The text was updated successfully, but these errors were encountered: