Binary number manipulation
Bill Sneddon
bsneddonNOspam at yahoo.com
Wed Dec 3 13:39:45 EST 2003
More information about the Python-list mailing list
Wed Dec 3 13:39:45 EST 2003
- Previous message (by thread): Binary number manipulation
- Next message (by thread): Binary number manipulation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Georgy Pruss wrote: > "Tim Roberts" <timr at probo.com> wrote in message news:350rsvkbsht8rgs1fsjjc7vkktf87sahi7 at 4ax.com... > | SBrunning at trisystems.co.uk wrote: > | > > | >> 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) > | > | ...which, unfortunately, gives a FutureWarning in Python 2.3 if high > | happens to be larger than 32767. > > Yes, it's really annoying. I use (high * 65536 + low) instead. > > -Georgy > > Were are you getting you numbers from? Have you looked at the struct module? I am reading a binary file and use this command from struct module to convert to integer not sure if this helps you or not. mwB = struct.unpack('>H',mw)[0] # unpack big-endian unsigned short ..detuple it
- Previous message (by thread): Binary number manipulation
- Next message (by thread): Binary number manipulation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list