[Tutor] Problems with unsigned integers

Loptr Chaote loptr.chaote at gmail.com
Mon Dec 13 18:11:57 CET 2004


Hello everyone! 

I'm having problems with signed/unsigned (32bit) integers in python.
Example code:

  seq = 0L
  seq = socket.ntohl(struct.unpack("L", data[38:42])[0])
  print seq

This sometimes produces a negative output, how is that possible since
I booth initialized seq with "0L" and also specified "L" in unpack()?

-L.C


More information about the Tutor mailing list