Home » Math » Math_RPN » Bug #1028
wrong assumption of unary minus if it's preceded with space(s)
Details
| Submitted | 2004-03-17 02:58 UTC |
|---|---|
| From | weirdan at mail dot od dot ua |
| Assigned | mszczytowski |
| Status | Closed |
| Package | Math_RPN |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2004-03-17 02:58 UTC] weirdan at mail dot od dot ua
Description:
------------
if the '-' operator is preceded with space(s) it's assumed to be unary minus for the following operand
Reproduce code:
---------------
$inputString="2 - 1";//note the spaces
include "RPN.php";
$rpn=new Math_RPN;
$rpn->calculate($inputString,'deg',false);
var_dump($rpn->getInputArray());
var_dump($rpn->getRpnArray());
Expected result:
----------------
expected output:
array(3) {
[0]=>
string(1) "2"
[1]=>
string(1) "-"
[2]=>
string(1) "1"
}
array(3) {
[0]=>
string(1) "2"
[1]=>
string(1) "1"
[2]=>
string(1) "-"
}
Actual result:
--------------
actual output:
error: Syntax error
array(4) {
[0]=>
string(1) "2"
[1]=>
string(2) "-1"
[2]=>
string(1) "*"
[3]=>
string(1) "1"
}
array(4) {
[0]=>
string(1) "2"
[1]=>
string(2) "-1"
[2]=>
string(1) "1"
[3]=>
string(1) "*"
}