fnoori / Vivyd-Calculator

0 stars 0 forks source link

tan, cos, sin, sqrt, ln/log buttons should calculate answer without needing closed bracket. #27

Closed amairJD closed 7 years ago

amairJD commented 8 years ago

i.e sin(45, sqrt(25, etc all work out and calculate the answer without showing error.

refer to google or asus caculator to see what I mean.

fnoori commented 8 years ago

that's a part of google's "auto answer", the library we're using to parse the equation will spit an error if the brackets are incorrect

what if the user wants to enter more calculations after, this will result in "cos(2" being calculated and the only text in answerView will be the solution to "cos(2".

ie. the user wants to equate "sin(23) + 2 + cos(23) + log(22) + ln(pi)" this will result in "sin(23" being equated immediately, making the equation the user wants to calculate split up and they can't access the full equation any longer since "sin(23" was calculated separately from the rest

then when it's time to input "cos(23" it will be equated immediately, making the equation broken into even more pieces.

amairJD commented 8 years ago

Check out the asus/zen calculator, CALCU, and Calc+ which don't have auto answer that do what i'm saying. Also, I am not saying that if user enters cos(56, it calculates answer immediately (if that's what you meant, text is hard to communicate with sometimes :( ) I.e, if user enters sin(23 + 2, it will give the same answer as sin(23) + 2 when equal button is pressed.

One thing we could do, is do something like what calc+ does. Say user enters " cos(56 + 3 ". Before calculating, our program could automatically insert the closing bracket in the right place (if close brace is not equal to open brace) before passing it on to the library for calculation. I.e if (openBrace != closeBrace) { move cursor to open brace. increment cursor until next item is an operator or null insert close brace } // Continue as normal

Let's bring this up next meeting, I think it's an important feature because most people are accustomed to getting there answer straight away by entering cos(45 and the like, w/o close brackets.

fnoori commented 8 years ago

Ooohhhhh

fnoori commented 8 years ago

need to play with it a lot to see how I can implement that It's a simple concept yeah, implementing it will be more challenging than the pseudo code you wrote

amairJD commented 8 years ago

Definitely, I agree with that. Whatever get's the job done. And where the smileys at in Github man? All they got is damn :8ball: and :100:

fnoori commented 8 years ago

Try to input a simple equation with mismatched brackets into calc+. For example: sin((8 + 5 * ((5 - 3 / 2 calc+ simply appends brackets to the end of the equation, turning it into sin((8 + 5 + ((5 - 3 / 2)))) Regardless if what you intended to calculate was sin((8+5) * ((5-3) / 2))

To just add brackets to the end is within my knowledge.

On the other hand, what you're suggesting that the code should "know" where to insert brackets at the correct places is a much more larger and difficult problem. It will not be a wise investment of our time to try and figure out how to insert "smart bracket insertion", as opposed to simply appending brackets at the end (as calc+ does)

fnoori commented 8 years ago

Alright my friend, I have implemented it the way that calc+ does it I will clear up on what I'm thinking the next time we meet, this explaining programming to each other over text is infuriating.