0

Possible Duplicate:
What USEFUL bitwise operator code tricks should a developer know about?

Hi,

What are some neat tricks with using bit-wise operations. I know that unless you're programming in C you won't have much encounters with operating on bit level. Nonetheless, there are some neat tricks that you can apply in even higher level languages. Here are a few that I already know.

  1. bit mask: Can hold a collection of boolean values
  2. XOR Swap: Swap 2 values in place without a third variable
  3. XOR Linked List: Create a doubly linked list with each node only hold one address value

What are some others?

Community
  • 1
  • 1
ming_codes
  • 2,870
  • 25
  • 24

1 Answers1

0

find whether a number is odd or not

(number & 1)
chown
  • 51,908
  • 16
  • 134
  • 170
ultifinitus
  • 1,813
  • 2
  • 19
  • 32