Re: 2.3 -> 2.4: long int too large to convert to int
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Fri, 16 Sep 2005 01:33:52 -0000
On 2005-09-15, chrisperkins99@xxxxxxxxx <chrisperkins99@xxxxxxxxx> 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?
.
- References:
- Re: 2.3 -> 2.4: long int too large to convert to int
- From: chrisperkins99
- Re: 2.3 -> 2.4: long int too large to convert to int
- Prev by Date: Re: Software bugs aren't inevitable
- Next by Date: Re: help for conversion of NUMARRAY to PIL object
- Previous by thread: Re: 2.3 -> 2.4: long int too large to convert to int
- Next by thread: Re: 2.3 -> 2.4: long int too large to convert to int
- Index(es):
Relevant Pages
|