data conversion question (binary string to 'real string')

Bob Gailer bgailer at alum.rpi.edu
Fri Jul 25 14:42:53 EDT 2003


FWIW here's an interesting way to get at the bit:
if 13 is the number you want to represent in binary and you want 6 bits:
 >>> [13>>x & 1 for x in range(6,-1,-1)]
[0, 0, 0, 1, 1, 0, 1]

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003


More information about the Python-list mailing list