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

Breadcrumb

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

function BigInteger::testBit

Returns true if and only if the designated bit is set.

Computes ((this & (1<<n)) != 0).

Parameters

int $n The bit to test, 0-based.:

Throws

\InvalidArgumentException If the bit to test is negative.

File

vendor/brick/math/src/BigInteger.php, line 850

Class

BigInteger
An arbitrary-size integer.

Namespace

Brick\Math

Code

public function testBit(int $n) : bool {
    if ($n < 0) {
        throw new \InvalidArgumentException('The bit to test cannot be negative.');
    }
    return $this->shiftedRight($n)
        ->isOdd();
}

API Navigation

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