CodeBase - C++ Expression Evaluation Function
Return to the CodeBase listing
Category: Math / Physics
Version: 1.0
Information
Uploaded: 26th Oct 2010 15:23
Modified: 26th Oct 2010 15:26
Author: Nizze
Summary
An evaluation function which takes a string with a mathematical expression and calculates it.
Full Description
An evaluation function which takes a string with a mathematical expression and calculates it.<br /> <br /> It also includes a few other functions that the main function uses. Feel free to use them too, but the string class itself has a few almost identical which might be quicker to use though.<br /> <br /> To use it, call Evaluate(std::string expression). It returns the result as a float.<br /> <br /> These are the operators it can take:<br /> Arithmetic:<br /> * - Multiplication<br /> / - Division<br /> + - Addition<br /> - - Subtraction (or a negative number if given only a right value)<br /> ^ - Exponentiation<br /> Boolean:<br /> = - Equal<br /> > - Greater than<br /> < - Less than<br /> ! - Not<br /> <br /> Note that the only operator that can take only a right value is -, which then means a negative number. For instance, !5 isn't valid, and will only result in 0, even if it's !0. -4+3, however, is valid, and results in -1.
Comments
No comments yet.