function BigInteger::shiftedRight
Returns the integer right shifted by a given number of bits.
1 call to BigInteger::shiftedRight()
- BigInteger::shiftedLeft in vendor/
brick/ math/ src/ BigInteger.php - Returns the integer left shifted by a given number of bits.
File
-
vendor/
brick/ math/ src/ BigInteger.php, line 766
Class
- BigInteger
- An arbitrary-size integer.
Namespace
Brick\MathCode
public function shiftedRight(int $distance) : BigInteger {
if ($distance === 0) {
return $this;
}
if ($distance < 0) {
return $this->shiftedLeft(-$distance);
}
$operand = BigInteger::of(2)->power($distance);
if ($this->isPositiveOrZero()) {
return $this->quotient($operand);
}
return $this->dividedBy($operand, RoundingMode::UP);
}