Alain Ketterlin <al...@dpt-info.u-strasbg.fr>: > Marko Rauhamaa <ma...@pacujo.net> writes: > >> Alain Ketterlin <al...@dpt-info.u-strasbg.fr>: >> >>> No, it would not work for signed integers (i.e., with lo and hi of >>> int64_t type), because overflow is undefined behavior for signed. >> >> All architectures I've ever had dealings with have used 2's-complement >> integers. Overflow is well-defined, well-behaved and sign-independent >> wrt addition, subtraction and multiplication (but not division). > > You are confused: 2's complement does not necessarily mean modular > arithmetic. See, e.g., > http://stackoverflow.com/questions/16188263/is-signed-integer-overflow-still-undefined-behavior-in-c
Ah, ok, I misunderstood your point. However, what I meant originally is that the given uintX_t implementation would work even if it were given intX_t arguments, and the returned uintX_t can be assigned to an intX_t variable safely. Marko -- https://mail.python.org/mailman/listinfo/python-list