unsigned 32 bit arithmetic type?

sturlamolden sturlamolden at yahoo.no
Wed Oct 25 19:25:46 CEST 2006


Robin Becker wrote:

> > ULONG CalcTableChecksum(ULONG *Table, ULONG Length)
> > {
> > ULONG Sum = 0L;
> > ULONG *Endptr = Table+((Length+3) & ~3) / sizeof(ULONG);
> >
> > while (Table < EndPtr)
> > 	Sum += *Table++;
> > return Sum;
> > }

Is this what you want?

import numpy
def CalcTableChecksum(Table, Length=None):
   tmp = numpy.array(Table,dtype=numpy.uint32)
   if Length == None: Length = tmp.size
   endptr = ((Length+3) & ~3) / 4
   return (tmp[0:endptr]).sum()




More information about the Python-list mailing list