On 2005-09-15, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

>>   fcntl.ioctl(self.dev.fileno(),0xc0047a80,struct.pack("HBB",0x1c,0x00,0x00))
>>
>> I get an OverflowError: long int too large to convert to int

> You could sort-of fake it like this,
>
> def unsigned(val):
>     return struct.unpack('i', struct.pack('I', val))[0]
>
> fcntl.ioctl(self.dev.fileno(), unsigned(0xc0047a80), ...)

I rather like this

  if i & 0x8000000:
      i = -((i^0xffffffff)+1)  

As long as I'm obfscating the code, who can resist some bitwise
operations.  Of course it'll break on machines that don't use
2's compliment, but that's just iceing on the cake.

-- 
Grant Edwards                   grante             Yow!  I am having FUN... I
                                  at               wonder if it's NET FUN or
                               visi.com            GROSS FUN?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to