Skip to content

Commit

Permalink
R Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
markrogoyski committed Jul 27, 2021
1 parent 9a2ddf0 commit a45921a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Number/ArbitraryInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use MathPHP\Exception;
use MathPHP\Functions\BaseEncoderDecoder;
use MathPHP\Number\Rational;

/**
* Arbitrary Length Integer
Expand Down Expand Up @@ -148,7 +147,7 @@ public static function createZeroValue(): ObjectArithmetic
* @param string $value
* @param bool $positive
*/
protected function setVariables(string $value, bool $positive)
protected function setVariables(string $value, bool $positive): void
{
$value = \ltrim($value, \chr(0));
if ($value == '') {
Expand Down Expand Up @@ -286,7 +285,7 @@ public function isqrt(): ArbitraryInteger

// √0 = 0 edge case
if ($this->equals(0)) {
return new static(0);
return new ArbitraryInteger(0);
}

$length = \strlen($this->base256);
Expand Down Expand Up @@ -530,7 +529,7 @@ public function mod($divisor): ArbitraryInteger
*
* @param int|string|ArbitraryInteger $divisor
*
* @return array (int, mod)
* @return array<ArbitraryInteger> (int, mod)
*
* @throws Exception\BadParameterException
* @throws Exception\IncorrectTypeException
Expand Down Expand Up @@ -614,7 +613,7 @@ public function fullIntdiv($divisor): array
*
* @param int|string|ArbitraryInteger $exp
*
* @return ArbitraryInteger
* @return ArbitraryInteger|Rational
*
* @throws Exception\BadParameterException
* @throws Exception\IncorrectTypeException
Expand All @@ -623,14 +622,15 @@ public function pow($exp): ObjectArithmetic
{
$exp = self::create($exp);
if (!($this->equals(1) || $this->equals(-1)) && $exp->lessThan(0)) {
/** @var ArbitraryInteger $tmp */
$tmp = $this->pow($exp->negate());
if ($tmp->lessThan(\PHP_INT_MAX) && $tmp->greaterThan(\PHP_INT_MIN)) {
return new Rational(0, 1, $tmp->toInt());
}
throw new Exception\OutOfBoundsException('Integer is too large to be expressed as a Rational object.');
}
if ($exp->equals(0) || $this->equals(1)) {
return new static(1);
return new ArbitraryInteger(1);
}
if ($exp->abs()->equals(1)) {
return $this;
Expand Down

0 comments on commit a45921a

Please sign in to comment.