Results 1 to 4 of 4

Thread: Quick question about bitwise operators...

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Smile Quick question about bitwise operators...

    I know you 'or' things together when using style masks and stuff, so how do you determine if a value has been 'or'ed into the resulting value.

    Like:
    Code:
    long a;
    a = 9 | 3;
    so later on in the app, how do I determine that a contains 9?

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    Lively Member
    Join Date
    Oct 2001
    Posts
    80
    From what I can see - you can't.

    The result of 9|3=11
    That could have also come from
    10|1
    9|2
    10|3

    and that can keep on going. Now, you can technically figure out that this result contains a 9 by saying 11 & 9 - that would return 9 indicating that it does exist in this value, but you can't figure out if that was the actual number used to get 11.

  3. #3
    Zaei
    Guest
    That is why you use powers of two when setting flags... 1, 2, 4, 8, 16, 32, etc.

    Z.

  4. #4

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by Zaei
    That is why you use powers of two when setting flags... 1, 2, 4, 8, 16, 32, etc.

    Z.
    That makes sense. Thanks.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width