Announcement

Collapse
No announcement yet.

Get bit set from 32bit integer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get bit set from 32bit integer

    This returns a 32-bit integer that indicates which markers were present on the line. Bit 0 is set if marker 0 is present, bit 1 for marker 1 and so on.

    I want to check if bit 30 or 31 is set so how do I go about doing this?

  • #2
    Perform a bitwise AND with 0xC0000000 and check the result: nonzero means that at least one of the two bits was set.

    Ulrich

    Comment


    • #3
      And to get them individually;
      To check for the 30th: local bit30set = (Bitwise.And(integer, 0x40000000) ~= 0);
      To check for the 31st: local bit31set = (Bitwise.And(integer, 0x80000000) ~= 0);
      Bas Groothedde
      Imagine Programming :: Blog

      AMS8 Plugins
      IMXLH Compiler

      Comment


      • #4
        ^ thanks guys :yes

        Comment

        Working...
        X