def uint64(val):
    """Force `val` into unsigned 64-bit range.

    Note that the input is returned as an int, therefore
    any math on the result may no longer be in uint64 range.

    >>> uint64(0x10000000000000000)
    0
    >>> uint64(-1)
    18446744073709551615
    >>> uint64(0xFFFFFFFFFFFFFFF0)
    18446744073709551600
    >>> uint64(0x7FFFFFFFFFFFFFFF)
    9223372036854775807
    >>> uint64(0x8000000000000000)
    9223372036854775808
    """
    return val & 18446744073709551615
