@Test public void numberOfLeadingZerosOfByte() { for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; ++i) { byte b = (byte) i; int actual = MathUtils.numberOfLeadingZeros(b); int expected = b < 0 ? 0 : (b == 0 ? 8 : Integer.numberOfLeadingZeros(i) - 24); Assert.assertEquals(expected, actual); } }
public static int numberOfLeadingZeros(byte b) { return Integer.numberOfLeadingZeros(b & 0xFF) - 24; }
MathUtils { public static int numberOfLeadingZeros(byte b) { return Integer.numberOfLeadingZeros(b & 0xFF) - 24; } }
MathUtils { public static int numberOfLeadingZeros(byte b) { return Integer.numberOfLeadingZeros(b & 0xFF) - 24; } private  MathUtils(); }
MathUtils { public static int numberOfLeadingZeros(byte b) { return Integer.numberOfLeadingZeros(b & 0xFF) - 24; } private  MathUtils(); static int gcd(int a, int b); static byte[] nonNegativeLongToBigEndianBytes(int byteCount, long value); static long unsignedBigEndianBytesToNonNegativeLong(byte[] bytes); static int bitCountToByteCount(int bitCount); static byte[] doubleToBytes(double value); static double bytesToDouble(byte[] bytes); static int numberOfLeadingZeros(byte b); }
MathUtils { public static int numberOfLeadingZeros(byte b) { return Integer.numberOfLeadingZeros(b & 0xFF) - 24; } private  MathUtils(); static int gcd(int a, int b); static byte[] nonNegativeLongToBigEndianBytes(int byteCount, long value); static long unsignedBigEndianBytesToNonNegativeLong(byte[] bytes); static int bitCountToByteCount(int bitCount); static byte[] doubleToBytes(double value); static double bytesToDouble(byte[] bytes); static int numberOfLeadingZeros(byte b);  }