def signed_q(num:int) -> int:
    """Returns signed value of unsigned (or signed) 64-bit integer (struct fmt 'q')
    """
    return ((num & 0xffffffffffffffff) ^ 0x8000000000000000) - 0x8000000000000000