Shop OBEX P1 Docs P2 Docs Learn Events
addressing bits of a variable — Parallax Forums

addressing bits of a variable

agfaagfa Posts: 295
edited 2008-09-01 01:53 in Propeller 1
can an individual bit of variable be set, reset, or tested: if variable/bit2=1 then do something?

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2008-08-31 14:09
    1) To set a bit "n": x |= |< n

    2) To clear a bit "n": x &= ! |< n

    3) To toggle a bit "n": x ^= |< n

    4) To test for bit "n" true: IF x & |< n <> 0

    5) To test for bit "n" false: IF x & |< n == 0

    John Abshier
  • agfaagfa Posts: 295
    edited 2008-09-01 01:53
    thanks John.
Sign In or Register to comment.