java.lang.Integer.rotateRight()%uA0方法一向右位的指定的数回旋转指定int值的二进制补码表示形式而得到的值。 (移出的位的右边,或低位,再输入侧上的左侧,或高次。)
声明
以下是java.lang.Integer.rotateRight()方法的声明
public static int rotateRight(int i, int distance)
参数
-
i%uA0-- 这是int值。
-
distance%uA0-- 这是旋转的距离。
返回值
此方法返回由右由位的指定数的旋转指定的int值的二进制补码表示法得到的值。
异常
-
NA
例子
下面的例子显示java.lang.Integer.rotateRight()方法的使用。
package com.yiibai import java.lang.* public class IntegerDemo { public static void main(String[] args) { int n = 2 // returns the value obtained by rotating right for(int i = 0 i < 4 i++) { n = Integer.rotateRight(n, 4) System.out.println(n) } } }
让我们来编译和运行上面的程序,这将产生以下结果:
536870912 33554432 2097152 131072