Coder-Spirit / php-bignumbers

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

Division by zero error in div() #58

Closed maff closed 7 years ago

maff commented 7 years ago

When using the library for divisions at a higher scale, you can run into division by zero errors:

<?php

declare(strict_types=1);

use Litipk\BigNumbers\Decimal;

require_once __DIR__ . '/vendor/autoload.php';

$value = Decimal::create('12.99', 4);
$divisor = Decimal::create(2, 4);

var_dump($value->div($divisor));
Warning: bcdiv(): Division by zero in src/Decimal.php on line 1155

The affected part is the innerLog10 method used while calculating the division.

castarco commented 7 years ago

Hi @maff , thank you for your report. I'll work on the regression test and the fix, in a few hours this will be solved :) .

castarco commented 7 years ago

Solved!

maff commented 7 years ago

@castarco Thanks!