Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#1909 from denixport/ho…
Browse files Browse the repository at this point in the history
…tfix/math-tests

Math\BigInteger better tests
  • Loading branch information
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 412 deletions.
6 changes: 1 addition & 5 deletions src/BigInteger/Adapter/Bcmath.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ public function sqrt($operand)
*/
public function abs($operand)
{
if ('-' == $operand[0]) {
return substr($operand, 1);
}
return $operand;
return ltrim($operand, '-');
}

/**
Expand All @@ -183,7 +180,6 @@ public function mod($leftOperand, $rightOperand)
return bcmod($leftOperand, $rightOperand);
}


/**
* Raise a big integer to another, reduced by a specified modulus
*
Expand Down
7 changes: 6 additions & 1 deletion src/BigInteger/Adapter/Gmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public function init($operand, $base = null)
}
}

return gmp_strval(gmp_init($sign . $operand, $base));
$res = gmp_init($sign . $operand, $base);
if ($res === false) {
return false;
}

return gmp_strval($res);
}

/**
Expand Down
Loading

0 comments on commit b5ec01e

Please sign in to comment.