Skip to content

Commit 6080098

Browse files
committed
feat: Add Bitwise7 class to compare signed right shift on positive and negative integers
Add a program that: - Applies signed right shift (`>>`) to both positive and negative integers - Demonstrates how sign extension affects the result of shifting negative numbers - Includes a commented unsigned right shift (`>>>`) line for future comparison - Helps visualize bitwise behavior using binary interpretation.
1 parent 1b22595 commit 6080098

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Section5OperatorExpression/src/Bitwise7.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ public static void main(String[] args)
33
{
44
int x = 8; // 00001000 (Binary)
55
System.out.println(x >> 1); // 00000100 -> Output: 4
6+
//System.out.println(x >>> 2);
67

78
int y = -8; // 11111000 (Binary in Two's Complement)
89
System.out.println(y >> 1); // 11111100 -> Output: -4
910
}
10-
}
11+
}

0 commit comments

Comments
 (0)