justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: Please describe 3 or 4 of your favorite bitwise operator tricks
Asked by Will (70.173.80.x) on February 16 2014, 1:14am
Reply on February 16 2014, 4:48am (edited at February 17 2014, 5:32pm):
    Hmm I dunno if I really have favorite tricks. x & (x-1) for checking if something is a power of two is somewhat handy. Knowing how "x/2" and "x>>1" differ is important, IMO, as well as "x%2" vs "x&1" (what code is produced by each, and why it matters, depending on types of course). Most recently I discovered this, which had never come up:
    for (int x=-1;x<sizeof(x);x++) printf("x"); 

Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2025 Justin Frankel. | RSS