1
0
mirror of https://github.com/danog/math.git synced 2025-01-22 13:41:12 +01:00

Fixed mistakes in sqrt and its test

This commit is contained in:
Daniil Gentili 2016-07-30 00:54:56 +02:00
parent e2a4969440
commit b2a3499218
2 changed files with 2 additions and 2 deletions

View File

@ -447,7 +447,7 @@ final class BigDecimal extends BigNumber implements \Serializable
$guess = $this->quotient($two);
while (true) {
$last = $guess;
$guess = $this->quotient($guess)->add($guess)->quotient($two);
$guess = $this->quotient($guess)->plus($guess)->quotient($two);
// (($n / $guess) + $guess) / 2;
if($last->compareTo($guess) == 0) {
break;

View File

@ -1372,7 +1372,7 @@ class BigDecimalTest extends AbstractTestCase
public function testsqrt()
{
$this->assertSame(BigDecimal::of(625)->sqrt(), BigDecimal::of(25));
$this->assertSame(BigDecimal::of(625)->sqrt()->compareTo(25), 0);
}
/**