Skip to content

Commit

Permalink
Using gmp_intval() to get gmp_gcd() int result (fix for Travis)
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesbourgeat authored and roadster31 committed Nov 5, 2015
1 parent ae5c7b0 commit f0328fd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ before_script:
- composer self-update
- composer install --dev

script: phpunit
script: phpunit
2 changes: 1 addition & 1 deletion src/GCD.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function getGCD($numberA, $numberB)
}

if (function_exists("gmp_gcd")) {
return gmp_gcd($numberA, $numberB);
return gmp_intval(gmp_gcd($numberA, $numberB));
}

if ($numberA == 0 || $numberB == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function computeDividend($askedDividend, $askedDivisor, Number $number

protected function simplify()
{
if (1 < $gcd = (int) GCD::getGCD($this->dividend, $this->divisor)) {
if (1 < $gcd = GCD::getGCD($this->dividend, $this->divisor)) {
$this->dividend /= $gcd;
$this->divisor /= $gcd;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Lovenunu/Math/NumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
*/
class NumberTest extends PHPUnit_Framework_TestCase
{
public function testMult()
{
$numberA = new Number('1');
$numberB = $numberA->multiply('1.2393');

$this->assertEquals(1.2393, $numberB->getNumber(-1));
}

public function testNumberAdd()
{
$numberA = new Number('1.99');
Expand Down

0 comments on commit f0328fd

Please sign in to comment.