mirror of
https://github.com/danog/math.git
synced 2025-01-22 21:51:22 +01:00
Fixed mistakes in sqrt and its test
This commit is contained in:
parent
e2a4969440
commit
b2a3499218
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user