Re: [Tutor] back on bytes

2007-07-10 Thread Terry Carroll
On Sat, 7 Jul 2007, Alan Gauld wrote: > I'm intrigued as to why people are using weird combinations > of math to manipulate bitstrings given that Python has a full > set of bitwise operators. Surely it is easier and more obvious > to simply shift the bits right or left using >> and << and use > bi

Re: [Tutor] back on bytes

2007-07-07 Thread shawn bright
Well, I contacted the programmer of these controls and the reason they mask the MSB on these reports is to designate what type of sensor it is. If the MSB is set, the sensor is one type, if not, another. So, knowing that i could put these together ok. To me, the speed is of no consequence like it w

Re: [Tutor] back on bytes

2007-07-07 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote >> to simply shift the bits right or left using >> and << and use >> bitwise and/or operations than do all this multiplication and >> addition malarky. (Its also a lot faster!) > > Are you sure about that? With Python 2.5 on a MacBook Pro it seems > to >

Re: [Tutor] back on bytes

2007-07-07 Thread Kent Johnson
Alan Gauld wrote: > Surely it is easier and more obvious > to simply shift the bits right or left using >> and << and use > bitwise and/or operations than do all this multiplication and > addition malarky. (Its also a lot faster!) Are you sure about that? With Python 2.5 on a MacBook Pro it seems

Re: [Tutor] back on bytes

2007-07-07 Thread Alan Gauld
"Terry Carroll" <[EMAIL PROTECTED]> wrote >> In your formula ( (176 & 127) * 256 + 192 ) you're only using 7 >> bits >> of your high byte. Why are you masking off that last bit? > > Scrounging through some old code, I used to use this to pull out the > length: > > def ID3TagLength(s): >

Re: [Tutor] back on bytes

2007-07-07 Thread Terry Carroll
On Fri, 6 Jul 2007, Jerry Hill wrote: > In your formula ( (176 & 127) * 256 + 192 ) you're only using 7 bits > of your high byte. Why are you masking off that last bit? I know in MP3 files, some of the ID3 lengths are coded this way, i.e. as a four-byte field, each byte of which has the high-o

Re: [Tutor] back on bytes

2007-07-06 Thread Jerry Hill
On 7/6/07, shawn bright <[EMAIL PROTECTED]> wrote: > i have a number 12480 > i have a low byte of 192 and a high byte of 176 Maybe I'm being dense, but that doesn't make any sense at all to me. The high byte of 12480 is 48, and the low byte is 192, isn't it? Because (48 * 256) + 192 = 12480? In y

[Tutor] back on bytes

2007-07-06 Thread shawn bright
hello all, i have a number 12480 i have a low byte of 192 and a high byte of 176 so i can do this IDLE 1.2.1 No Subprocess >>> (176 & 127) * 256 + 192 12480 but if i start with the 12480, how do i get the two bytes (lo and hi) that make it up? i kinda know what i am doing here,