Long int to int

Tim Howarth tim at worthy.demon.co.uk
Mon Feb 11 14:17:28 CET 2002


In message <7xlme0fcku.fsf at ruckus.brouhaha.com>
          Paul Rubin <phr-n2002a at nightsong.com> wrote:

> Tim Howarth <tim at worthy.demon.co.uk> writes:

> > 0xFFFFFFFFL
> > to become
> > -1
> 
> That's the result I get in Python 2.2.  I don't have 2.1 on this system.
> 1.5.2 raises an exception when it tries to convert 0xFFFFFFFFL to hex.

Stupid me, yes so it does - I think I might have tried using 8FFFFFFF
for some reason !

> > besides I grew up believeing eval==evil.
> 
> I guess you could use binascii and struct to convert the hex string to
> a binary string and then pack the binary string into an integer.
> Ouch.

Exactly, it's a lot of bother for a simple request!

I'll probably stick with my bitshift version.
 
-- 
___
 |im    ---- ARM Powered ----



More information about the Python-list mailing list