Binary number manipulation

SBrunning at trisystems.co.uk SBrunning at trisystems.co.uk
Mon Dec 1 06:22:17 EST 2003


> From:	Matthew A. Berglund [SMTP:matt at satbp.com]
> I am very new to python so I am working on some ass-umptions which may be
> incorrect (please forgive me).
> 
> I am working on a problem that requires me to take 2 decimal integers,
> each of which represents half of a word. I need to slap these things
> together and get out another decimal integer.
> A couple of questions:
> 1. Is there a way to typecast a variable as a binary?
 
AFAIK, no.
 
> 2. If 1 is no, does that mean that I need to do all the manipulation in
> some icky string format and then go back?
 
I use:

((high << 16) | low)
 
> I do see the bit-wise operations available and this looks like I need to
> simply perform these on my integers? Can it really be that simple?
 
Yup.

Cheers,
Simon Brunning,
http://www.brunningonline.net/simon/blog/
--LongSig




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.





More information about the Python-list mailing list