def _convert_hex_str_to_int(val):
    """Convert hexadecimal formatted ids to signed int64"""
    if val is None:
        return None
    hex_num = int(val, 16)
    if hex_num > 9223372036854775807:
        hex_num -= 18446744073709551616
    assert -9223372036854775808 <= hex_num <= 9223372036854775807
    return hex_num
