PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Math » Math_RPN » Bug #1028

wrong assumption of unary minus if it's preceded with space(s)

Details

Submitted2004-03-17 02:58 UTC
Fromweirdan at mail dot od dot ua
Assignedmszczytowski
StatusClosed
PackageMath_RPN
PHP VersionIrrelevant
OSIrrelevant
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) "*"
}