org.bouncycastle.util.Integers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk14 Show documentation
Show all versions of bcprov-jdk14 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.
package org.bouncycastle.util;
public class Integers
{
public static int numberOfLeadingZeros(int i)
{
if (i <= 0)
{
return (~i >>> (31 - 5)) & (1 << 5);
}
int n = 1;
if (0 == (i >>> 16)) { n += 16; i <<= 16; }
if (0 == (i >>> 24)) { n += 8; i <<= 8; }
if (0 == (i >>> 28)) { n += 4; i <<= 4; }
if (0 == (i >>> 30)) { n += 2; i <<= 2; }
n -= (i >>> 31);
return n;
}
public static int rotateLeft(int i, int distance)
{
return (i << distance) ^ (i >>> -distance);
}
public static int rotateRight(int i, int distance)
{
return (i >>> distance) ^ (i << -distance);
}
public static Integer valueOf(int value)
{
return new Integer(value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy