public function withoutTrailingZeroes(): self
    {
        // if bit string was empty
        if (!strlen($this->_string)) {
            return new self("");
        }
        $bits = $this->_string;
        // count number of empty trailing octets
        $unused_octets = 0;
        for ($idx = strlen($bits) - 1; $idx >= 0; --$idx, ++$unused_octets) {
            if ($bits[$idx] != "\x0") {
                break;
            }
        }
        // strip trailing octets
        if ($unused_octets) {
            $bits = substr($bits, 0, -$unused_octets);
        }
        // if bit string was full of zeroes
        if (!strlen($bits)) {
            return new self("");
        }
        // count number of trailing zeroes in the last octet
        $unused_bits = 0;
        $byte = ord($bits[strlen($bits) - 1]);
        while (!($byte & 0x01)) {
            $unused_bits++;
            $byte >>= 1;
        }
        return new self($bits, $unused_bits);
    }