[Python-Dev] Drop support for ones' complement machines?

Mark Dickinson dickinsm at gmail.com
Tue Dec 1 18:25:04 CET 2009


On Tue, Dec 1, 2009 at 5:22 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
> or a workaround.  E.g., for an unsigned long x,
>
>  ((x) >= 0 ? (long)(x) : ~(long)~(x))
>
> always gives the appropriate wraparound semantics (I think), assuming

Sorry;  should have tested.  Try:

((x) <= LONG_MAX ? (long)(x) : ~(long)~(x))

Mark


More information about the Python-Dev mailing list