Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Shift {
- public static void main(String[] argv) {
- long seed = -9223372036854775808L; // -2^63 coded as 10..0 00..0
- int shifted_as_int = (int)(seed >>> 32); // coded as 10..0
- System.out.println(shifted_as_int); // -2^31 since interpreted as signed
- System.out.println(shifted_as_int % 100); // -48 -> bad
- long shifted_as_long = (long)(seed >>> 32); // coded as 0..0 10..0
- System.out.println(shifted_as_long % 100); // 48 -> good
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement