Interrupt Enable

Life is a series of rude awakenings

Showing posts with label idea. Show all posts
Showing posts with label idea. Show all posts

Sunday, November 30, 2008

isTwoPower

Very simple and elegant function to test if a number is a power of two.

int isTwoPower(int n){
if( n < 1 )
return 0;
return !(n & (n-1));
}
Posted by Daniel Băluță at 2:42 AM 1 comment:
Labels: algorithm, idea, tricks
Older Posts Home
Subscribe to: Posts (Atom)

About Me

My photo
Daniel Băluță
romanian blood,oltenian heart.
View my complete profile

Blog roll

  • Linux Journal - The Original Magazine of the Linux Community
    New AMD P-State Patch Delivers Major Linux Gaming Performance Boost
    4 days ago
  • Ubuntu Geek
    Clusterssh – Administer multiple ssh or rsh shells simultaneously
    5 years ago
  • Joel on Software
    Welcome, Prashanth!
    6 years ago
  • Linux Magazine
    Scripting, Part Two: Looping for Fun and Profit
    15 years ago
  • Rusty's Bleeding Edge Page
    Finally, Rusty's Blog Moves to WordPress
    16 years ago

Daniel Baluta's shared items

Blog Archive

  • ▼  2011 (1)
    • ▼  June (1)
      • /* TODO */
  • ►  2009 (6)
    • ►  May (1)
    • ►  March (3)
    • ►  February (2)
  • ►  2008 (5)
    • ►  December (3)
    • ►  November (2)
Simple theme. Theme images by gaffera. Powered by Blogger.