Coder-Spirit / php-bignumbers

A robust library to handle immutable big numbers inside PHP applications
MIT License
131 stars 29 forks source link

bcdiv() division by zero error #53

Closed djmattyg007 closed 7 years ago

djmattyg007 commented 7 years ago

When running the following code, I get a PHP division by zero warning: PHP Warning: bcdiv(): Division by zero in vendor/litipk/php-bignumbers/src/Decimal.php on line 1140

<?php
declare(strict_types=1);
require("vendor/autoload.php");
use Litipk\BigNumbers\Decimal;

$d1 = Decimal::create(192078120.5, 28);
$d2 = Decimal::create(31449600, 28);

echo $d1->div($d2);

If I remove the .5 from the first value, the division by zero warning does not occur. Similarly, if I pass 28 as the second parameter to div(), the warning does not occur.

I'm using v0.8.2 of this package, running on PHP 7.1.2 (cli) with opcache enabled. Xdebug is not installed. Please don't hesitate to request more information.

castarco commented 7 years ago

Wow, shame on me. I've confirmed the issue, and I'm working on it. Thanks for reporting it.

castarco commented 7 years ago

Fixed!

djmattyg007 commented 7 years ago

Wow, thanks for resolving this so quickly!