Returns a literal for a bit value that can be safely used in SQL statements.

@param string|null $bits The bit value.

@return string
183379
public function quoteBit(?string $bits): string
  {
    if ($bits===null || $bits==='')
    {
      return 'null';
    }

    return "b'".$this->mysqli->real_escape_string($bits)."'";
  }
397921
function _rule_checkbit($str, $bit) {
        if (!isset($this->_rd[$str])) return false;
        $bit2 = $this->_rd[$str]['bit'];
        return ($bit & $bit2 ? true : false);
    }
652043
private function doGetBinaryBitsetLeInt()
    {
        $bin = \pack(\PHP_INT_SIZE === 8 ? 'P' : 'V', $this->bitset);
        return \substr($bin, 0, (int)\ceil($this->enumerationCount / 8));
    }
1291325
public static function bits2Tones($bits) {
    	$tones = array();
    	$n = $bits;
    	$i = 0;
    	while ($n > 0) {
    		if ($bits & (1 << $i)) {
    			$tones[] = $i;
	    		$n = $n & ~(1 << $i); // turn the bit off
    		}
    		$i++;
    	}
    	return $tones;
    }
690066
public static function tones2Bits($tones) {
    	$bits = 0;
    	if (empty($tones)) {
return 0;}
    	foreach ($tones as $tone) {
    		$bits += pow(2, $tone);
    	}
    	return $bits;
    }
584087
function setPrecision($bits)
    {
        $this->precision = $bits;
        if (MATH_BIGINTEGER_MODE != self::MODE_BCMATH) {
            $this->bitmask = new static(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256);
        } else {
            $this->bitmask = new static(bcpow('2', $bits, 0));
        }

        $temp = $this->_normalize($this);
        $this->value = $temp->value;
    }
698541
public function getTopLeftOnBit() : ?array
    {
        $bitsOffset = 0;

        while ($bitsOffset < count($this->bits) && 0 === $this->bits[$bitsOffset]) {
            ++$bitsOffset;
        }

        if (count($this->bits) === $bitsOffset) {
            return null;
        }

        $x = intdiv($bitsOffset, $this->rowSize);
        $y = ($bitsOffset % $this->rowSize) << 5;

        $bits = $this->bits[$bitsOffset];
        $bit = 0;

        while (0 === ($bits << (31 - $bit))) {
            ++$bit;
        }

        $x += $bit;

        return [$x, $y];
    }
314252
public static function quoteDecimal($value): string
  {
    if ($value===null || $value==='') return 'null';

    if (is_int($value) || is_float($value)) return (string)$value;

    return "'".self::$mysqli->real_escape_string($value)."'";
  }
367317
public function iushln($bits) {
        assert(is_integer($bits) && $bits >= 0);
        if ($bits < 54) {
            $this->bi = $this->bi->mul(1 << $bits);
        } else {
            $this->bi = $this->bi->mul((new BigInteger(2))->pow($bits));
        }
        return $this;
    }
287241
protected function _geti(&$data, $bits)
    {
        $bytes = $bits / 8;
        $value = null;

        if (strlen($data) >= $bytes) {
            $value = ord($data[0]);
            if ($bytes >= 2) {
                $value += (ord($data[1]) << 8);
            }
            if ($bytes >= 4) {
                $value += (ord($data[2]) << 16) + (ord($data[3]) << 24);
            }
            $data = substr_replace($data, '', 0, $bytes);
        }

        return $value;
    }
628314
private function doSetBinaryBitsetLeBin($bitset): void
    {
        $size   = \strlen($this->bitset);
        $sizeIn = \strlen($bitset);

        if ($sizeIn < $size) {
            // add "\0" if the given bitset is not long enough
            $bitset .= \str_repeat("\0", $size - $sizeIn);
        } elseif ($sizeIn > $size) {
            if (\ltrim(\substr($bitset, $size), "\0") !== '') {
                throw new InvalidArgumentException('out-of-range bits detected');
            }
            $bitset = \substr($bitset, 0, $size);
        }

        // truncate out-of-range bits of last byte
        $lastByteMaxOrd = $this->enumerationCount % 8;
        if ($lastByteMaxOrd !== 0) {
            $lastByte         = $bitset[-1];
            $lastByteExpected = \chr((1 << $lastByteMaxOrd) - 1) & $lastByte;
            if ($lastByte !== $lastByteExpected) {
                throw new InvalidArgumentException('out-of-range bits detected');
            }

            $this->bitset = \substr($bitset, 0, -1) . $lastByteExpected;
        }

        $this->bitset = $bitset;
    }
313728
public static function fromDecimal($size, $values = 0)
	{
		$size = min((int) $size, PHP_INT_SIZE);
		$values <<= PHP_INT_SIZE - $size;
		$bits = new BitArray($size);

		for ($i = 0; $i < PHP_INT_SIZE; $i++)
		{
			$bits->data[$i] = chr(($values & (0xff << (PHP_INT_SIZE - 8))) >> (PHP_INT_SIZE - 8));
			$values <<= 8;
		}

		return $bits;
	}
148225
protected function getValueDescription($value)
    {
        switch (true) {
            case (is_numeric($value)):
                $value = strval($value);
                break;

            case (is_bool($value) && $value):
                $value = '(boolean) true';
                break;

            case (is_bool($value) && !$value):
                $value = '(boolean) false';
                break;

            case (is_null($value)):
                $value = 'null value';
                break;

            default:
                break;
        }

        return $value;
    }
457042
public function bitOr( $value1, $value2 )
    {
        $value1 = $this->getIdentifier( $value1 );
        $value2 = $this->getIdentifier( $value2 );
        return "( {$value1} | {$value2} )";
    }
325773
public function getBottomRightOnBit() : ?array
    {
        $bitsOffset = count($this->bits) - 1;

        while ($bitsOffset >= 0 && 0 === $this->bits[$bitsOffset]) {
            --$bitsOffset;
        }

        if ($bitsOffset < 0) {
            return null;
        }

        $x = intdiv($bitsOffset, $this->rowSize);
        $y = ($bitsOffset % $this->rowSize) << 5;

        $bits = $this->bits[$bitsOffset];
        $bit  = 0;

        while (0 === BitUtils::unsignedRightShift($bits, $bit)) {
            --$bit;
        }

        $x += $bit;

        return [$x, $y];
    }
1274364
private function urlEncode6bit($b)
    {
        if ($b < 10) {
            return chr(48 + $b);
        }
        $b -= 10;
        if ($b < 26) {
            return chr(65 + $b);
        }
        $b -= 26;
        if ($b < 26) {
            return chr(97 + $b);
        }
        $b -= 26;
        if ($b == 0) {
            return '-';
        }
        if ($b == 1) {
            return '_';
        }

        return '?';
    }
937011
private function _parseAttrStringValue(int &$offset): string
    {
        $idx = $offset;
        if ($idx >= $this->_len) {
            return "";
        }
        if ('"' == $this->_dn[$idx]) { // quoted string
            $val = $this->_parseQuotedAttrString($idx);
        } else { // string
            $val = $this->_parseAttrString($idx);
        }
        $offset = $idx;
        return $val;
    }