Page 1 of 1
Bit from a Byte?
Posted: Sun Mar 25, 2012 9:27 am
by DirkB
How to? Just read a bit from a byte.
Thanks
Dirk
Re: Bit from a Byte?
Posted: Sun Mar 25, 2012 10:32 am
by medelec35
Hi Dirk,
If you only want the result to be a 1 or 0 (E.g for bit 4 ) then I would use the format:
Bit = Byte & 16 - (16-1)
Or of course you can use Bit = Byte & 16 - 15
Just so long as the last value is 1 less of first number
You could use other formats:
E.g Hex: Bit = Byte & 0x10 - (0x10 -1)
Or Binary:
Bit = Byte & 0b10000 - (0b10000-1)
Hope this helps.
Martin
Re: Bit from a Byte?
Posted: Sun Mar 25, 2012 5:52 pm
by DirkB
Hi Matin,
cool, this works well!
Ok, how to: Combine a Byte 8 bit and a Byte 4 bit to a Byte with 12 bit word lenght.
8 bit word is lsb, 4 bit word is msb, and - later split them back to original word lenght.
Hope you understand my bad english
Thank you very much
Dirk
Re: Bit from a Byte?
Posted: Sun Mar 25, 2012 9:28 pm
by medelec35