Shop OBEX P1 Docs P2 Docs Learn Events
storing bits — Parallax Forums

storing bits

Mike WMike W Posts: 105
edited 2007-08-30 01:49 in General Discussion
As an example:
·
tmpW2_MSB = 1110_0100
·
tmpW2_MSB.0· =· 0
tmpW2_MSB.1 =· 0
·
if I wanted to store two bits of the byte - tmpW2_MSB
·
say tmpW2_MSB.0 and tmpW2_MSB_.1
·
so that
·
some_Variable· =· 00
·
How do I do this?
·
I tried·· some_variable· =· tmpW2_MSB.0,· tmpW2_MSB.1 ·and that didn’t work
·
So I tried some_variable =· tmpW2_MSB.0· + tmpW2_MSB.1· that worked but for the wrong reason.
·
·I don’t want to add them, I just want to store them side by side as one

Mike W

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-08-30 01:49
    value1 var byte
    value2 var byte

    value1 = 13 '0000_1101
    value2 = value1 AND 3 '0000_0001

    the AND 3 extracts only bits b0 and b1

    regards peter
Sign In or Register to comment.