How to? Just read a bit from a byte.
Thanks
Dirk
Bit from a Byte?
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Bit from a Byte?
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
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
Martin
Re: Bit from a Byte?
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times