BitStream::getBitsSigned(size_t nbits)
{
    unsigned long long bits = read_bits(this->p, this->bit_offset,
                                        this->bits_available, nbits);
    long long result = 0;
    if (static_cast<long long>(bits) > 1LL << (nbits - 1))
    {
        result = static_cast<long long>(bits -(1ULL << nbits));
    }
    else
    {
        result = static_cast<long long>(bits);
    }
    return result;
}
BitStream::getBitsSigned(size_t nbits)
{
    unsigned long long bits = read_bits(this->p, this->bit_offset,
                                        this->bits_available, nbits);
    long long result = 0;
    if (static_cast<long long>(bits) > 1LL << (nbits - 1))
    {
        result = static_cast<long long>(bits -(1ULL << nbits));
    }
    else
    {
        result = static_cast<long long>(bits);
    }
    return result;
}