Wishing I had a cute phrase here.

  • Contact
  • Projects
  • Blog
  • About

Results tagged “Bitwise” from iJeff.com

Bit Flags and Fancy Math

By Jeffrey Price on February 5, 2008 10:07 PM | Permalink | Comments (0)
Over on CF-Talk today, Dennis Powers had a problem with selecting the correct records when dealing with bit flags. I'm a big fan of flags and bitwise math, so I jumped in and helped him out. I had to think about the operations a bit (no pun intended) too long, so I decided to drop myself a note as a refresher.

When dealing with bit flags, here is a handy cheatsheet:

myMask = 1st and 8th flags set (10000001 -> 2^7 + 2^0 -> 129)

myVar & myMask = myMask (All masked flags are set)
myVar & myMask > 0 (At least one masked flag is set)
myVar & myMask = 0 (None of the masked flags are set)
myVar = myMask (All masked flags set, all other flags not set)

Happy masking!

Tags:

  • Bitwise

Search

  • Case sensitive
  • Regex search

Tags

  • AIR (1)
  • Bitwise (1)
  • coldfusion (1)
  • CSS (1)
  • documentation (1)
  • frameworks (1)
  • Hurricanes (1)
  • JavaScript IE7 (1)
  • Jokes (1)
  • Unit Testing (1)
  • Subscribe to feed Subscribe to this blog's feed
  • Subscribe to feed Search results matching “Bitwise”
Powered by Movable Type 4.01
Powered by Movable Type Publishing Platform
This blog is licensed under a Creative Commons License.