[Tutor] binary data as string?
"Jörg Wölke"
lumbricus at gmx.net
Fri Apr 16 18:53:03 EDT 2004
> > > for n in range(8):
> > > print (data & mask) and 1 or 0,
> > > mask = mask << 1
> > s/<</>>/
> >
> > > Will print out the bit pattern of 42...
>
> Actually no, that'll drop the 1 off the end and
> only print the first bit accurately.
silly me - I didn`t see that you where shifting mask not data!
> the bits in reverse order!
Why not shift data and reverse the result?
That seemed to be the more general approach to me.
>
> mask = 128 # = 1000000
If it is guarateed, that the Data unit is 8 bits.
> Should do it properly...
>
> :-)
>
> Alan G.
Greetings, J"o!
--
Sie duerfen diesen Satz zitieren.
NEU : GMX Internet.FreeDSL
Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/info
More information about the Tutor
mailing list