Last active
June 26, 2020 16:48
-
-
Save PeterZhukov/e20970713e3187aa9879e1ae6a581f49 to your computer and use it in GitHub Desktop.
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
| package com.example.helloworld; | |
| public class Shift { | |
| public static void showShift(){ | |
| //byte val = 1; int tmp; | |
| byte val = (byte) (1 << 7); int tmp; | |
| int r; | |
| for(int i = 0; i < 32; i++){ | |
| tmp = val; | |
| //tmp <<= i; | |
| tmp >>= i; | |
| for(long t = Integer.MAX_VALUE + 1L; t > 0; t /= 2){ | |
| if ((tmp & t) != 0) System.out.print("1 "); | |
| else System.out.print("0 "); | |
| } | |
| r = tmp; | |
| System.out.print("r: " + r + " (byte)r: " + (byte)r); | |
| System.out.println(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment