What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Calulator Plugin

Calulator Plugin
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Calulator Plugin
quote:
Originally posted by Orkblutt
/xcalc 666/77*8
=1.08                             ==> FALSE !!!

/xcalc (666/77)*8          ==> TRUE !!!
=69.20
That makes me wonder how you do the calculation and what method you use... because first of all in many language of today there is already an evaluation function for such things (dunno about C++ though). If you use that, you only need to pass the string and you would never have problems like that....

If you do seperate the numbers yourself then, again, this is some basic flaw in your algorithm, as it would be very easy to do such things in a home-made function:

* use a recursive function
* get the deepest linked parenthesis
* calculate the result of that:
  "*" and "/" coming first, then "+" and "-"
  Also calculate from LEFT to RIGHT!!! <== the error you made ( * or / doesn't take precedence over each other, just like + and - doesnt....)
    1) 666 / 77
    2) 8.64 * 8
  not:
    1) 77 * 8
    2) 666 / 616

* update the "string"
* exit the function and go up 1 level

This is a realy realy basic way in doing it (without optimazations), and you would never have a problem with parenthesis...

note about using "-": it is best that you don't implement substractions, but only additions! If a minus is used, it should be considered part of the number, not a math-function. If you do this you also wont have problems with: "8 - 5" because your function would calculate "8 + -5", but most importantly, you can do "8 * -5" without any additional coding...


So... I'm realy interested in the method you use...

PS:
http://www.codeproject.com/cpp/FastMathParser.asp
http://www.codeproject.com/cpp/RPNcalculator.asp
http://www.programmersheaven.com/zone3/cat415/30915.htm
http://www.informit.com/articles/article.asp?p=21484
http://trubetskoy1.narod.ru/english/ppne.html <= implement this and you also have a PPN calculator...

This post was edited on 09-14-2004 at 06:02 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-14-2004 05:15 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Calulator Plugin - by Orkblutt on 09-13-2004 at 10:55 PM
RE: Calulator Plugin - by RebelSean on 09-13-2004 at 11:23 PM
RE: Calulator Plugin - by Orkblutt on 09-13-2004 at 11:25 PM
RE: Calulator Plugin - by RebelSean on 09-13-2004 at 11:28 PM
RE: Calulator Plugin - by Orkblutt on 09-13-2004 at 11:33 PM
RE: Calulator Plugin - by riahc4 on 09-13-2004 at 11:58 PM
RE: Calulator Plugin - by Orkblutt on 09-13-2004 at 11:59 PM
RE: Calulator Plugin - by RebelSean on 09-14-2004 at 12:55 AM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 02:06 AM
RE: Calulator Plugin - by RaceProUK on 09-14-2004 at 12:51 PM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 01:07 PM
RE: Calulator Plugin - by jameslives on 09-14-2004 at 03:01 PM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 03:03 PM
RE: Calulator Plugin - by jameslives on 09-14-2004 at 03:04 PM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 03:06 PM
RE: Calulator Plugin - by lhunath on 09-14-2004 at 03:07 PM
RE: Calulator Plugin - by jameslives on 09-14-2004 at 03:08 PM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 03:15 PM
RE: Calulator Plugin - by jameslives on 09-14-2004 at 03:23 PM
RE: Calulator Plugin - by RaceProUK on 09-14-2004 at 04:08 PM
RE: Calulator Plugin - by lhunath on 09-14-2004 at 04:10 PM
RE: Calulator Plugin - by RaceProUK on 09-14-2004 at 04:12 PM
RE: Calulator Plugin - by aNILEator on 09-14-2004 at 04:26 PM
RE: Calulator Plugin - by CookieRevised on 09-14-2004 at 05:15 PM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 05:55 PM
RE: Calulator Plugin - by MessEnGer on 09-14-2004 at 06:21 PM
RE: Calulator Plugin - by Millenium_edition on 09-14-2004 at 06:35 PM
RE: Calulator Plugin - by RaceProUK on 09-14-2004 at 07:29 PM
RE: Calulator Plugin - by Orkblutt on 09-14-2004 at 09:58 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On