Created
          January 9, 2012 09:49 
        
      - 
      
- 
        Save davestevens/1582231 to your computer and use it in GitHub Desktop. 
    Best way to unsign right shift a signed integer?
  
        
  
    
      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
    
  
  
    
  | int unsignedRightShift(int input, char shift) { | |
| if(shift == 0) { | |
| return input; | |
| } | |
| return (((input >> 1) & 0x7fffffff) >> (shift - 1)); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment