Tushar Goel wrote: . . .. First you move 0x20(32) position to the left and makes it signed then you right shift it 32 position and makes it unsigned. . . .
I tried a bitwise AND with -1 but even casting it to an
int didn't help. What you are doing with the << 0x20 is moving the entire number 0x20 bits to the left, so the right half consists entirely of 0s. All 32 lower order bits are now on the left. Then you move the whole lot back so the right 32 lower order bits are replaced where they started but the left half is filled with 0s. I should have written line 9 like this:-
System.out.printf("The bottom 32 bits of i unsigned are %d=0x%<x%n",
… then you can see the hex output for 3158851493 which will of course be bc483fa5.