Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
07-07-2009, 01:05 PM #1
- Join Date
- Mar 2009
- Munich, Germany
- Thanked 13 Times in 13 Posts
Converting a string to a command?
I was wondering if it was possible to convert a string like "2x * x + 3x +5" to operators and integers so that this could actually be calculated? I'm sure there is a way but I really don't know how I would go about doing that. I have designed an algorithem before that was able to get easy functions simply by reading each character and then deciding on what to do, but that was very limited, and would be way to complex.
Anybody have a tip of how this can be achieved?
07-07-2009, 03:28 PM #2
- Join Date
- Jun 2002
- Thanked 328 Times in 324 Posts
You would need to parse it and then run the correct commands based on whats in the string. It wouldn't be too hard, if you want to support more complex equations that use parenthesis and brackets it would be harder but not by much. You also have to remember the order of operations in math, you can't simply execute from left to right.OracleGuy