Created
          June 17, 2014 13:35 
        
      - 
      
 - 
        
Save cynx/ccc61a89f38f8ddefc46 to your computer and use it in GitHub Desktop.  
    C function to rotate right
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | unsigned rightrot(unsigned x, unsigned n) | |
| { | |
| while (n > 0) { | |
| if ((x & 1) == 1) | |
| x = (x >> 1) | ~(~0U >> 1); | |
| else | |
| x = (x >> 1); | |
| n--; | |
| } | |
| return x; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment