Closed alesak closed 4 years ago
PHP 5.6 MoneyPHP version 3.2.0
How about php7+?
How about php7+?
Haven't tested it, we are still forced to run it on 5.6 as lots of our older projects are not fully compatible with PHP7
Can you add a failing test as PR? Then I will fix it.
I cannot replicate this with PHP 5.6
Sorry, it looks like the value has to be -500:
$value = new Money('-500', new Currency('USD'));
$p = $value->divide(110); //throws exception
/vendor/moneyphp/money/src/Number.php on line 287
/vendor/moneyphp/money/src/Number.php(38): Money\Number::parseFractionalPart('-54545454545455')
/vendor/moneyphp/money/src/Number.php(56): Money\Number->__construct('-4', '-54545454545455')
/vendor/moneyphp/money/src/Number.php(89): Money\Number::fromString('-4.-54545454545...')
/vendor/moneyphp/money/src/Calculator/GmpCalculator.php(191): Money\Number::fromNumber('-4.-54545454545...')
/vendor/moneyphp/money/src/Money.php(456): Money\Calculator\GmpCalculator->round('-4.-54545454545...', 1)
/vendor/moneyphp/money/src/Money.php(338): Money\Money->round('-4.-54545454545...', 1)
default.php(55): Money\Money->divide(110)
PHPCalculator & BcMathCalculator works
Can you add a failing test as PR? Then I will fix it.
I will try to do so but I am not sure when I can get the chance
@alesak I already created the PR.
@frederikbosch thanks for looking into this!
I'd like to add that the problem with the GMP calculator occurs in multiply() as well; e.g., if you multiply -0.09
times 0.01
you get InvalidArgumentException: Invalid fractional part -9. Invalid digit - found
.
@pmjones Is your bug resolved with PR #546? Maybe it is time to merge it then.
My coworker informs me that is it not resolved by #546; I presume because the PR applies to divide() but not multiply(). (We do have a workaround in place.)