a 32 bit number to integer

R

Ricardo Quesada

Hi,

In python 2.0, this number was an integer:
0x88776655

but in python 2.4 it is a long (every number > 0x7fffffff it is a long)

in python 2.4, is there a way to convert that number to a integer
(notice that it only occupies 32 bits) ?


thanks,
riq.
 
P

Paul Rubin

Ricardo Quesada said:
0x88776655

but in python 2.4 it is a long (every number > 0x7fffffff it is a long)

in python 2.4, is there a way to convert that number to a integer
(notice that it only occupies 32 bits) ?

It would be -2005440939 but that's maybe not what you want.
 
D

Dave Hansen

Hi,

In python 2.0, this number was an integer:
0x88776655

but in python 2.4 it is a long (every number > 0x7fffffff it is a long)

in python 2.4, is there a way to convert that number to a integer
(notice that it only occupies 32 bits) ?

Well, the sign bit's gonna be set no matter what. But the following
might work for you...
return int(0x80000000 - x)


Regards,
-=Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,282
Messages
2,571,404
Members
48,096
Latest member
Kenkian2628

Latest Threads

Top