Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BigInteger.php

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\Math

Code

public function getBitLength() : int {
    if ($this->value === '0') {
        return 0;
    }
    if ($this->isNegative()) {
        return $this->abs()
            ->minus(1)
            ->getBitLength();
    }
    return \strlen($this->toBase(2));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal