java.lang.Integer.rotateRight()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中java.lang.Integer.rotateRight()方法的一些代码示例,展示了Integer.rotateRight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.rotateRight()方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:rotateRight

Integer.rotateRight介绍

[英]Rotates the bits of the specified integer to the right by the specified number of bits.
[中]将指定整数的位向右旋转指定位数。

代码示例

代码示例来源:origin: MovingBlocks/Terasology

  1. @Override
  2. public int get(int src) {
  3. // RGBA becomes ARGBA by a simple rotation
  4. return Integer.rotateRight(src, Byte.SIZE);
  5. }

代码示例来源:origin: lealone/Lealone

  1. private static int rot(int i, int count) {
  2. return Integer.rotateRight(i, count);
  3. }

代码示例来源:origin: stackoverflow.com

  1. int n = 0x55005500; // Binary 01010101000000000101010100000000
  2. int k = 13;
  3. System.err.printf("%08x%n", Integer.rotateRight(n, k));

代码示例来源:origin: com.h2database/h2

  1. private void decryptBlock(byte[] in, byte[] out, int off) {
  2. int x0 = Bits.readInt(in, off);
  3. int x1 = Bits.readInt(in, off + 4);
  4. int x2 = Bits.readInt(in, off + 8);
  5. int x3 = Bits.readInt(in, off + 12);
  6. int k = key;
  7. x1 = Integer.rotateRight(x1, x0) ^ k;
  8. x3 = Integer.rotateRight(x3, x0) ^ k;
  9. x0 = Integer.rotateRight(x0, x1) ^ k;
  10. x2 = Integer.rotateRight(x2, x1) ^ k;
  11. Bits.writeInt(out, off, x0);
  12. Bits.writeInt(out, off + 4, x1);
  13. Bits.writeInt(out, off + 8, x2);
  14. Bits.writeInt(out, off + 12, x3);
  15. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. { c = rotateRight( c, 30); a -= s4(b, c, d, e,w2[ 64]);}
  2. { d = rotateRight( d, 30); b -= s4(c, d, e, a,w2[ 63]);}
  3. { e = rotateRight( e, 30); c -= s4(d, e, a, b,w2[ 62]);}
  4. { a = rotateRight( a, 30); d -= s4(e, a, b, c,w2[ 61]);}
  5. { b = rotateRight( b, 30); e -= s4(a, b, c, d,w2[ 60]);}
  6. { c = rotateRight( c, 30); a -= s3(b, c, d, e,w2[ 59]);}
  7. { d = rotateRight( d, 30); b -= s3(c, d, e, a,w2[ 58]);}
  8. { e = rotateRight( e, 30); c -= s3(d, e, a, b,w2[ 57]);}
  9. { a = rotateRight( a, 30); d -= s3(e, a, b, c,w2[ 56]);}
  10. { b = rotateRight( b, 30); e -= s3(a, b, c, d,w2[ 55]);}
  11. { c = rotateRight( c, 30); a -= s3(b, c, d, e,w2[ 54]);}
  12. { d = rotateRight( d, 30); b -= s3(c, d, e, a,w2[ 53]);}
  13. { e = rotateRight( e, 30); c -= s3(d, e, a, b,w2[ 52]);}
  14. { a = rotateRight( a, 30); d -= s3(e, a, b, c,w2[ 51]);}
  15. { b = rotateRight( b, 30); e -= s3(a, b, c, d,w2[ 50]);}
  16. { c = rotateRight( c, 30); a -= s3(b, c, d, e,w2[ 49]);}
  17. { d = rotateRight( d, 30); b -= s3(c, d, e, a,w2[ 48]);}
  18. { e = rotateRight( e, 30); c -= s3(d, e, a, b,w2[ 47]);}
  19. { a = rotateRight( a, 30); d -= s3(e, a, b, c,w2[ 46]);}
  20. { b = rotateRight( b, 30); e -= s3(a, b, c, d,w2[ 45]);}
  21. { c = rotateRight( c, 30); a -= s3(b, c, d, e,w2[ 44]);}
  22. { d = rotateRight( d, 30); b -= s3(c, d, e, a,w2[ 43]);}
  23. { e = rotateRight( e, 30); c -= s3(d, e, a, b,w2[ 42]);}
  24. { a = rotateRight( a, 30); d -= s3(e, a, b, c,w2[ 41]);}
  25. { b = rotateRight( b, 30); e -= s3(a, b, c, d,w2[ 40]);}
  26. { c = rotateRight( c, 30); a -= s2(b, c, d, e,w2[ 39]);}

代码示例来源:origin: net.mikera/mikera

  1. public int hashCode() {
  2. int result=0;
  3. for(int i=0; i<count; i++) {
  4. result^=data[i];
  5. result=Integer.rotateRight(result, 1);
  6. }
  7. return result;
  8. }

代码示例来源:origin: jpcsp/jpcsp

  1. private int getScrambleDataSector(long fuseId, int partitionNumber) {
  2. if (partitionNumber == 3) {
  3. return 0x3C22812A;
  4. }
  5. int scramble = ((int) fuseId) ^ Integer.rotateRight((int) (fuseId >> 32), partitionNumber * 3);
  6. scramble ^= 0x556D81FE;
  7. if (scramble == 0) {
  8. scramble = Integer.rotateRight(0x556D81FE, partitionNumber);
  9. }
  10. return scramble;
  11. }

代码示例来源:origin: stackoverflow.com

  1. public static int encrypt(int value, byte key) {
  2. int result=value;
  3. for (int i=0; i<=(key&255); i++) {
  4. result=Integer.rotateRight(result,7)^(i+0xCAFEBABE);
  5. }
  6. return result;
  7. }

代码示例来源:origin: net.mikera/mikera

  1. public static <T> int hashCode(T[] data) {
  2. int result=0;
  3. for(int i=0; i<data.length; i++) {
  4. result^=data[i].hashCode();
  5. result=Integer.rotateRight(result, 1);
  6. }
  7. return result;
  8. }

代码示例来源:origin: stackoverflow.com

  1. public static <T> int hashCode(T[] data) {
  2. int result=0;
  3. for(int i=0; i<data.length; i++) {
  4. result^=data[i].hashCode();
  5. result=Integer.rotateRight(result, 1);
  6. }
  7. return result;
  8. }

代码示例来源:origin: stackoverflow.com

  1. public class Binary {
  2. public static void main(String[] args) {
  3. Integer i = 18;
  4. System.out.println(Integer.toBinaryString(i));
  5. i = Integer.rotateRight(i, 2);
  6. System.out.println(Integer.toBinaryString(i));
  7. }
  8. }

代码示例来源:origin: com.github.blasd.apex/apex-java

  1. public static final int positiveUnpack2(long packed) {
  2. // Move the higher bit as lower bit: if packed >= 0, we then are sure to have a 0 as first bit
  3. // Then, this 0 bit it put back as last bit: the integer is guaranteed to be positive
  4. return Integer.rotateRight((int) (Long.rotateLeft(packed, 1) & MASK), 1);
  5. }

代码示例来源:origin: net.mikera/mikera

  1. public static<T> int hashCode(Iterator<T> data) {
  2. int result=0;
  3. while(data.hasNext()) {
  4. result^=hashCodeWithNulls(data.next());
  5. result=Integer.rotateRight(result, 1);
  6. }
  7. return result;
  8. }

代码示例来源:origin: com.github.cormoran-io.pepper/pepper

  1. public static final int positiveUnpack2(long packed) {
  2. // Move the higher bit as lower bit: if packed >= 0, we then are sure to have a
  3. // 0 as first bit
  4. // Then, this 0 bit it put back as last bit: the integer is guaranteed to be
  5. // positive
  6. return Integer.rotateRight((int) (Long.rotateLeft(packed, 1) & MASK), 1);
  7. }

代码示例来源:origin: net.imagej/ij

  1. /** Returns a hashcode for this Roi that typically changes
  2. if it is moved, even though it is still the same object. */
  3. public int getHashCode() {
  4. return hashCode() ^ (new Double(getXBase()).hashCode()) ^
  5. Integer.rotateRight(new Double(getYBase()).hashCode(),16);
  6. }

代码示例来源:origin: jtransc/jtransc

  1. static private void testBitsOps() {
  2. System.out.println("testBitsOps:");
  3. System.out.println("Integer.bitCount:" + Integer.bitCount(0x12345678));
  4. System.out.println("Integer.reverse:" + Integer.reverse(0x12345678));
  5. System.out.println("Integer.reverse:" + Integer.reverse(0xF2345678));
  6. System.out.println("Integer.reverseBytes:" + Integer.reverseBytes(0x12345678));
  7. System.out.println("Integer.reverseBytes:" + Integer.reverseBytes(0xF2345678));
  8. System.out.println("Integer.rotateLeft:" + Integer.rotateLeft(0x12345678, 13));
  9. System.out.println("Integer.rotateRight:" + Integer.rotateRight(0xF2345678, 27));
  10. System.out.println("Short.reverseBytes:" + Short.reverseBytes((short) 0x1234));
  11. System.out.println("Short.reverseBytes:" + Short.reverseBytes((short) 0xF234));
  12. }

代码示例来源:origin: jpcsp/jpcsp

  1. public final void doWSBH(int rd, int rt) {
  2. if (rd != 0) {
  3. setRegister(rd, Integer.rotateRight(Integer.reverseBytes(getRegister(rt)), 16));
  4. }
  5. }

代码示例来源:origin: net.mikera/mikera

  1. public int hashCode() {
  2. if (blocks.length==0) return 0;
  3. int r=blocks[0].hashCode();
  4. for (int i=1; i<blocks.length; i++) {
  5. r=Integer.rotateRight(r,blocks[i].size());
  6. r^=blocks[i].hashCode();
  7. }
  8. return r;
  9. }

代码示例来源:origin: jpcsp/jpcsp

  1. public final void doROTRV(int rd, int rt, int rs) {
  2. if (rd != 0) {
  3. // no need of "getRegister(rs) & 31", rotateRight does it for us
  4. setRegister(rd, Integer.rotateRight(getRegister(rt), getRegister(rs)));
  5. }
  6. }

代码示例来源:origin: net.mikera/mikera

  1. public int hashCode() {
  2. int r= Integer.rotateRight(front.hashCode(),back.size());
  3. r^=back.hashCode();
  4. return r;
  5. }
  6. }

相关文章