aboutsummaryrefslogtreecommitdiff
path: root/bits.c
diff options
context:
space:
mode:
Diffstat (limited to 'bits.c')
-rw-r--r--bits.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bits.c b/bits.c
index 0182646..0bae750 100644
--- a/bits.c
+++ b/bits.c
@@ -143,7 +143,7 @@ unsigned reverse(unsigned v) {
* Difficulty: 3
*/
int logicalShift(int x, int n) {
- return 2;
+ return (x >> n) & ~(((1 << 31) >> n) << 1);
}
/*