>>> a & 128 will be 128 if the high bit in a is set, 0 if it is not.
>>>
>>
>> Only for an 8 bit integer! Most integers nowadays are
>> 32 bit so you need to use 0x8000 to get the msb!
> Right, but if you read the thread it is about byte values read from a
> file so presumably he is tal
Alan Gauld wrote:
> "Kent Johnson" <[EMAIL PROTECTED]> wrote
>
>> This is also a good application of bitwise operations.
>>
>> a & 128 will be 128 if the high bit in a is set, 0 if it is not.
>>
>
> Only for an 8 bit integer! Most integers nowadays are
> 32 bit so you need to use 0x80
Hey thanks for all the help guys, i am at least pulling some values
that make sense.
i feel more like i am on my way.
thanks again
shawn
On 2/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
> "Kent Johnson" <[EMAIL PROTECTED]> wrote
> > This is also a good application of bitwise operations.
> >
>
"Kent Johnson" <[EMAIL PROTECTED]> wrote
> This is also a good application of bitwise operations.
>
> a & 128 will be 128 if the high bit in a is set, 0 if it is not.
Only for an 8 bit integer! Most integers nowadays are
32 bit so you need to use 0x8000 to get the msb!
Alan G.
"shawn bright" <[EMAIL PROTECTED]> wrote
> but how do i read the individual bits of a byte
> how do i know what the msb of a is ?
See my reply to Johan in the thread Struct the solution...
Basically you can use a bitwise and with a mask
containing only the bit you are interested in. Johan
wa
even better, thanks much for this.
shawn
On 2/21/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Luke Paireepinart wrote:
> > shawn bright wrote:
> >> lo there all,
> >>
> >> i am reading a binary file with open('myfile', 'rb')
> >>
> >> then i do a read(1) to read one byte. cool so far.
> >>
> >> b
Luke Paireepinart wrote:
> shawn bright wrote:
>> lo there all,
>>
>> i am reading a binary file with open('myfile', 'rb')
>>
>> then i do a read(1) to read one byte. cool so far.
>>
>> but how do i read the individual bits of a byte
>>
>> i mean if i have a = read(1)
>>
>> how do i know what the m
great, thanks for this. appreciate it a lot.
sk
On 2/20/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
shawn bright wrote:
> lo there all,
>
> i am reading a binary file with open('myfile', 'rb')
>
> then i do a read(1) to read one byte. cool so far.
>
> but how do i read the individual bits
shawn bright wrote:
> lo there all,
>
> i am reading a binary file with open('myfile', 'rb')
>
> then i do a read(1) to read one byte. cool so far.
>
> but how do i read the individual bits of a byte
>
> i mean if i have a = read(1)
>
> how do i know what the msb of a is ?
>
> i need to know becaus
lo there all,
i am reading a binary file with open('myfile', 'rb')
then i do a read(1) to read one byte. cool so far.
but how do i read the individual bits of a byte
i mean if i have a = read(1)
how do i know what the msb of a is ?
i need to know because i have to see if the msb is set and i
10 matches
Mail list logo