Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread ALAN GAULD
>>> 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

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread Kent Johnson
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

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread shawn bright
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. > > >

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread Alan Gauld
"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.

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread Alan Gauld
"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

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread shawn bright
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

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread Kent Johnson
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

Re: [Tutor] how to read one bit of a byte

2007-02-20 Thread shawn bright
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

Re: [Tutor] how to read one bit of a byte

2007-02-20 Thread Luke Paireepinart
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

[Tutor] how to read one bit of a byte

2007-02-20 Thread shawn bright
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