• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Mathematical expression translator Frontrunner Junior Member Posts: 16 Threads: 1 Joined: Apr 2008 04-29-2008, 07:49 PM You are very welcome Ralph, I am glad it helped! Hi LPG, If I may give you a tip ? Use an array to split the whole input string in to tokens. This makes it easier to keep track of symbols like brackets etc. and once you know where to place the pow statement you can simply change the array. So (5^5)^5 could look like this: Token\$(1) = "(" Token\$(2) = "5" Token\$(3) = "^" Token\$(4) = "5" Token\$(5) = ")" Token\$(6) = "^" Token\$(7) = "5" To become pow((pow(5,5)),5) Token\$(1) = "pow" + Token\$(1) Token\$(2) = "(pow(" + Token\$(2) Token\$(3) = "," Token\$(4) = "5" Token\$(5) = ")" + Token\$(5) Token\$(6) = "," Token\$(7) = Token\$(7) + ")" Note that all tokens which are ^ simply become a comma. The trick is to take track of the brackets! I hope that helps. And then one more tricky example when it comes to unary operators If -8 - -5 = 1 - -2 ^ 2 Then Becomes If -8 - -5= 1- -pow(2,2) Then Cheers, Frontrunner « Next Oldest | Next Newest »

 Messages In This Thread Mathematical expression translator - by Frontrunner - 04-21-2008, 06:15 PM Re: Mathematical expression translator - by wildcard - 04-21-2008, 11:48 PM Re: Mathematical expression translator - by Frontrunner - 04-22-2008, 12:08 AM Re: Mathematical expression translator - by wildcard - 04-22-2008, 12:17 PM Re: Mathematical expression translator - by Frontrunner - 04-22-2008, 02:57 PM Re: Mathematical expression translator - by Ralph - 04-23-2008, 05:40 AM Re: Mathematical expression translator - by Frontrunner - 04-23-2008, 11:54 AM Re: Mathematical expression translator - by Ralph - 04-23-2008, 11:09 PM Re: Mathematical expression translator - by Frontrunner - 04-24-2008, 01:25 AM Re: Mathematical expression translator - by wildcard - 04-24-2008, 02:06 AM Re: Mathematical expression translator - by Frontrunner - 04-24-2008, 02:52 AM Re: Mathematical expression translator - by Ralph - 04-24-2008, 02:56 AM Re: Mathematical expression translator - by wildcard - 04-24-2008, 03:19 AM Re: Mathematical expression translator - by Ralph - 04-24-2008, 07:51 AM Re: Mathematical expression translator - by Frontrunner - 04-25-2008, 01:39 AM Re: Mathematical expression translator - by wildcard - 04-25-2008, 02:30 AM Re: Mathematical expression translator - by Frontrunner - 04-25-2008, 03:23 PM Re: Mathematical expression translator - by Ralph - 04-25-2008, 07:40 PM Re: Mathematical expression translator - by Ralph - 04-26-2008, 12:40 AM Re: Mathematical expression translator - by Frontrunner - 04-26-2008, 01:59 AM Re: Mathematical expression translator - by Ralph - 04-26-2008, 04:33 AM Re: Mathematical expression translator - by Frontrunner - 04-26-2008, 01:48 PM Re: Mathematical expression translator - by Ralph - 04-29-2008, 08:30 AM Re: Mathematical expression translator - by LPG - 04-29-2008, 10:57 AM Re: Mathematical expression translator - by Frontrunner - 04-29-2008, 07:49 PM Re: Mathematical expression translator - by wildcard - 04-30-2008, 02:53 AM Re: Mathematical expression translator - by Frontrunner - 04-30-2008, 03:06 AM Re: Mathematical expression translator - by LPG - 04-30-2008, 09:06 AM Re: Mathematical expression translator - by Frontrunner - 04-30-2008, 02:27 PM Re: Mathematical expression translator - by Frontrunner - 05-03-2008, 07:16 PM Re: Mathematical expression translator - by yetifoot - 05-07-2008, 07:37 PM Re: Mathematical expression translator - by Frontrunner - 05-08-2008, 03:23 AM Re: Mathematical expression translator - by wildcard - 05-13-2008, 06:26 PM Re: Mathematical expression translator - by Frontrunner - 06-02-2008, 02:23 AM Re: Mathematical expression translator - by wildcard - 06-04-2008, 12:29 PM Re: Mathematical expression translator - by Agamemnus - 08-06-2008, 01:17 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)