Jan-28-2018, 05:30 AM
(This post was last modified: Jan-28-2018, 05:31 AM by Gribouillis.)
Here is what I got in a python 2 console
Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.maxint 9223372036854775807 >>> sys.maxint + 1 9223372036854775808L >>> sys.maxint + 1 == 2 ** 63 True >>> - sys.maxint - 1 -9223372036854775808 >>> - sys.maxint - 2 -9223372036854775809LSo a good test seems to be
>>> def int_suffices(n): ... return - 2 ** 63 <= n < 2 ** 63 ... # OR >>> def int_suffices(n): return n >> 63 in (-1, 0) ...