BitWriter::writeBitsSigned(long long val, size_t bits)
{
    unsigned long long uval = 0;
    if (val < 0)
    {
        uval = (1ULL << bits) + static_cast<unsigned long long>(val);
    }
    else
    {
        uval = static_cast<unsigned long long>(val);
    }
    writeBits(uval, bits);
}
BitWriter::writeBitsSigned(long long val, size_t bits)
{
    unsigned long long uval = 0;
    if (val < 0)
    {
        uval = (1ULL << bits) + static_cast<unsigned long long>(val);
    }
    else
    {
        uval = static_cast<unsigned long long>(val);
    }
    writeBits(uval, bits);
}