提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
循环右移
//package com.nowjava; /* 来 自* 时代Java - N o w J a v a . c o m */ public class Main { public static void main(String[] argv) throws Exception { byte b = 2; int count = 2; System.out.println(circularBitShiftRight(b, count)); } public static byte circularBitShiftRight(byte b, int count) { if (count < 0) count = count * -1; if (count > 7) count = count % 8;/** from 时 代 Java - nowjava.com**/ if (count == 0) return b; if (b >= 0) return (byte) ((b >>> count) | (b << Byte.SIZE - count));