Timeline for Parsing expression with exponents and evaluating
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 21, 2015 at 1:37 | comment | added | penguinguy | Okay, I was trying to follow PEMDAS. I programmed it to evaluate an expression like a human would. | |
Dec 21, 2015 at 1:31 | comment | added | πάντα ῥεῖ | @penguinguy I'm afraid that's actually not easy to understand stuff. What you really need is to make your parser producing an abstract syntax tree (AST), and evaluating all of the sub expressions by walking through it too get the final result. That's way too broad to be described with an answer here. There are whole books written about that. All I can say is, that your approach is way too naive, sorry. | |
Dec 21, 2015 at 1:24 | comment | added | penguinguy | Im so confused sorry, could you re-state from the beginning in easier to understand terms what is wrong with the order it handles them in now? Like an example of what would cause it to give a invalid output. | |
Dec 21, 2015 at 1:19 | comment | added | πάντα ῥεῖ | @penguinguy That's what's called the natural operator precedence, yes. Implement this in your parser in a generic way. | |
Dec 21, 2015 at 1:18 | comment | added | penguinguy | I thought your not supposed to evaluate addition before power function? | |
Dec 21, 2015 at 1:16 | comment | added | πάντα ῥεῖ | @penguinguy Different order by means of evaluating the addition for the exponent before the power function of course. | |
Dec 21, 2015 at 1:14 | comment | added | penguinguy | What do you mean when you say "Require brackets to group math expressions being processed in different order" ,"different order" specifically. | |
Dec 21, 2015 at 1:14 | history | edited | πάντα ῥεῖ | CC BY-SA 3.0 |
added 1 character in body
|
Dec 21, 2015 at 1:08 | history | edited | πάντα ῥεῖ | CC BY-SA 3.0 |
added 308 characters in body
|
Dec 21, 2015 at 0:48 | history | edited | πάντα ῥεῖ | CC BY-SA 3.0 |
added 53 characters in body
|
Dec 21, 2015 at 0:41 | comment | added | penguinguy | What are some of the other approaches that I took that could be improved? | |
Dec 21, 2015 at 0:37 | history | answered | πάντα ῥεῖ | CC BY-SA 3.0 |