Package Proposal: Math_RPN
| From: | Maciej Szczytowski | Date: | Sun, 25 May 2003 11:32:14 +0000 |
| Subject: | Package Proposal: Math_RPN | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-16698@lists.php.net to get a copy of this message | ||
Hi,
I wrote a class that can make and calculate a RPN (reversed polish
notation) expression.
RPN is formal logic system which allowed mathematical expressions to be
specified without parentheses by placing the operators before or after the
operands.
For example 2+5*7 in RPN looks 2,5,7,*,+
You can take a look at the source code and example here:
http://www.maciek.maribex.wizja.net.pl/rpn/
Sample usage:
$expression = '(3+2)*(7-sin(30)*log(10))';
require_once 'Math/RPN.php';
$rpn = new RPN(false);
$value = $rpn->getValue($input); // 32.5
Any questions, comments, or suggestions?
Regards,
Maciek Szczytowski
admin@e-rower.pl