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



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?
.



Relevant Pages

  • [tip:x86/cleanups] x86: Clean up mtrr/cleanup.c
    ... static int __init ... save_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek, ... unsigned long base, size, def, dummy; ...
    (Linux-Kernel)
  • Re: Large text files and searching text
    ... This header is not null or /n delimited as it just runs into the data ... The value is syntax for a quoted string in PostScript, and def is the assignment ... int data = headers.Find; ... BOOL FindIntParamter(const CString & pattern, const CString & headers, int & result) ...
    (microsoft.public.vc.mfc)
  • Re: Large text files and searching text
    ... This header is not null or /n delimited as it just runs into the data ... The value is syntax for a quoted string in PostScript, and def is ... int data = headers.Find; ... BOOL FindIntParamter(const CString & pattern, const CString & headers, int ...
    (microsoft.public.vc.mfc)
  • Re: does Ruby not support multiple "initialize" methods for a class???
    ... two "initialize" methods with their own specific method signature to cover ... def initialize *argv, &block ... def initialize_from_int int ... def initialize template ...
    (comp.lang.ruby)
  • Re: structure and malloc
    ... ABC *abc; ... memoryfor structure DEF and its constituting structure ABC. ...
    (comp.lang.c)