def to_fixed(s, prec):
    """Convert a raw mpf to a fixed-point big integer"""
    sign, man, exp, bc = s
    offset = exp + prec
    if sign:
        if offset >= 0:
            return -man << offset
        else:
            return -man >> -offset
    elif offset >= 0:
        return man << offset
    else:
        return man >> -offset
