Calculator
I'm trying to make a calculator that only support multipling , adding and subtraction with a specified synax
Synax will look alike the following :- { 5.0 + { { 5 * 5 } - { 3 * 4 } } } Regex pattren : "^^.*\{.*\d+(?:.*\..*\d*).*[*+-].*\d+(?:.*\..*\d*).*\}.*$" Now i'm real confused on how to turn that string (equation) to an answer. |
Re: Calculator
Look into Shunting-yard algorithm and Postfix/Reverse Polish notation, that should help you.
|
Re: Calculator
Solved using regex
Fixed pattren : "^^.*(\{ *(\d+(?: *\. *\d* *| *))([\*\+\-]) *(\d+(?: *\. *\d* *| *))\}).*$" Seems like I was missing brackets for string parsing. |
| All times are GMT -4. The time now is 17:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.