rightshifttest.java

来自「JAVA编程思想第四版英文原版习题答案. pdf原版的」· Java 代码 · 共 20 行

JAVA
20
字号
// operators/RightShiftTest.java
// TIJ4 Chapter Operators, Exercise 11, page 116 
/* Start with a number that has a binary one in the most significant position
* (hint: Use a hexadecimal constant). Using the signed right-shift operator,
* right shift it all the way through all of its binary positions each time
* displaying the result using Integer.toBinaryString().
*/ 

import org.greggordon.tools.*;

public class RightShiftTest {
	public static void main(String [] args) {
		int h = 0x10000000;
		P.rintln(Integer.toBinaryString(h));
		for(int i = 0; i < 28; i++) {
			h >>>= 1;
			P.rintln(Integer.toBinaryString(h));
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?