Unsigned integer arithmetic

Thomas Heller thomas.heller at ion-tof.com
Wed Apr 26 05:44:39 EDT 2000


> Hi all,
>
> I'm having a lot of trouble with arithmetic manipulation of numbers above
> 0x7fffffff. Whilst an integer is represented in a 32 bit word, as you'd
> expect, 0x80000000 - 0xffffffff are treated as negative numbers. However,
I
> want to treat a 32 bit number as an unsigned value, and be able to do i =
i
> + 1 for an integer number above 0x7fffffff without getting an overflow.
>

What about writing an Uint32 class? You could implement __add__, __hex__,
and so on...

Thomas





More information about the Python-list mailing list