chriskonnertz/string-calc

Wrong calculations

simoheinonen opened this issue · 4 comments

$calculator = new ChrisKonnertz\StringCalc\StringCalc();
echo $calculator->calculate('1-1-1') . PHP_EOL;

prints 1

$calculator = new ChrisKonnertz\StringCalc\StringCalc();
echo $calculator->calculate('1-1+1') . PHP_EOL;

prints -1

Hello,

I will check this tomorrow.

I've added your example calculations to the test calculations: 50c75e9

I will investigate why they cause wrong results.

Seem's to be an issue with PHP 5.6's implementation of Quicksort (uasort). It seems to put items with the same comparison value (0) in the opposite order as PHP >= 7. I think I worked with HP 7.0 here so I did not notice that.

Bug has been fixed for PHP 5.6: f131daa
Test is green now: https://travis-ci.org/chriskonnertz/string-calc/jobs/260698794
Sorry for the inconvenience.