A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/328163.html below:

2.3 -> 2.4: long int too large to convert to int

2.3 -> 2.4: long int too large to convert to intGrant Edwards grante at visi.com
Thu Sep 15 21:33:52 EDT 2005
On 2005-09-15, chrisperkins99 at gmail.com <chrisperkins99 at gmail.com> 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?

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4