function BigInteger::getBitLength
Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit.
For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation. Computes (ceil(log2(this < 0 ? -this : this+1))).
1 call to BigInteger::getBitLength()
- BigInteger::getLowestSetBit in vendor/
brick/ math/ src/ BigInteger.php - Returns the index of the rightmost (lowest-order) one bit in this BigInteger.
File
-
vendor/
brick/ math/ src/ BigInteger.php, line 791
Class
- BigInteger
- An arbitrary-size integer.
Namespace
Brick\MathCode
public function getBitLength() : int {
if ($this->value === '0') {
return 0;
}
if ($this->isNegative()) {
return $this->abs()
->minus(1)
->getBitLength();
}
return \strlen($this->toBase(2));
}