"Craig" <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm trying to switch binary numbers around so that the MSB becomes the
> LSB etc. Is there an easy way of doing this as I can't seem to find
> anything. If you could help that would be great. Thanks and good
> luck.
Are these Python ints, or
Terry Reedy wrote:
> "Craig" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Thanks so much for the response. I have an array of individual bytes
> > which will eventually make up a binary bitmap image that is loaded onto
> > an LCD screen (1 = black dot, 0 = white dot). At th
"Craig" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thanks so much for the response. I have an array of individual bytes
> which will eventually make up a binary bitmap image that is loaded onto
> an LCD screen (1 = black dot, 0 = white dot). At the moment each byte
> is rever
On Dec 6, 7:20 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> It's a little less obtuse if you spell it this way:
>
> def flipbits(x):
> """reverse bits in a byte"""
> x1 = x << 4 | x >> 4
> x2 = (x1 & 0x33) << 2 | (x1 & 0xcc) >> 2
> return (x2 & 0x55) << 1 | (x2 & 0xaa) >> 1
>
G
On 2006-12-06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Yet another solution:
>
> def flipbits(x):
> """reverse bits in a byte"""
> x1 = x << 4 | x >> 4
> x2 = (x1 & 51) << 2 | (x1 & 204) >> 2
> return (x2 & 85) << 1 | (x2 & 170) >> 1
>
> The idea is to first swap the two nyb
On Dec 6, 6:01 pm, "Craig" <[EMAIL PROTECTED]> wrote:
> Thanks so much for the response. I have an array of individual bytes
> which will eventually make up a binary bitmap image that is loaded onto
> an LCD screen (1 = black dot, 0 = white dot). At the moment each byte
> is reversed to what it s
Craig wrote:
> Matimus wrote:
>
> > Craig wrote:
> > > I'm trying to switch binary numbers around so that the MSB becomes the
> > > LSB etc.
> >
> > What do you mean 'binary numbers'? They are all binary. If you mean the
> > int type, they are 32 bits long and there are 16 bits between the MSB
> >
On 2006-12-06, Craig <[EMAIL PROTECTED]> wrote:
> Thanks so much for the response. I have an array of
> individual bytes which will eventually make up a binary bitmap
> image that is loaded onto an LCD screen (1 = black dot, 0 =
> white dot). At the moment each byte is reversed to what it
> shou
Matimus wrote:
> Craig wrote:
> > I'm trying to switch binary numbers around so that the MSB becomes the
> > LSB etc.
>
> What do you mean 'binary numbers'? They are all binary. If you mean the
> int type, they are 32 bits long and there are 16 bits between the MSB
> and LSB (Most/Least Significa
Craig wrote:
> I'm trying to switch binary numbers around so that the MSB becomes the
> LSB etc.
What do you mean 'binary numbers'? They are all binary. If you mean the
int type, they are 32 bits long and there are 16 bits between the MSB
and LSB (Most/Least Significant _Byte_). Do you want to swa
10 matches
Mail list logo