Here you can find the source of ShiftAwayTrailingZerosTwoElements(int[] arr)
static int ShiftAwayTrailingZerosTwoElements(int[] arr)
//package com.java2s; public class Main { static int ShiftAwayTrailingZerosTwoElements(int[] arr) { int a0 = arr[0]; int a1 = arr[1]; int tz = CountTrailingZeros(a0); if (tz == 0) { return 0; }//from w w w .ja v a 2 s . co m { if (tz < 32) { int carry = a1 << (32 - tz); arr[0] = (int) ((a0 >> tz) & (0x7fffffff >> (tz - 1))) | (int) carry; arr[1] = (a1 >> tz) & (0x7fffffff >> (tz - 1)); return tz; } tz = CountTrailingZeros(a1); if (tz == 32) { arr[0] = 0; } else if (tz > 0) { arr[0] = (a1 >> tz) & (0x7fffffff >> (tz - 1)); } else { arr[0] = a1; } arr[1] = 0; return 32 + tz; } } private static int CountTrailingZeros(int numberValue) { if (numberValue == 0) { return 32; } int i = 0; { if ((numberValue << 16) == 0) { numberValue >>= 16; i += 16; } if ((numberValue << 24) == 0) { numberValue >>= 8; i += 8; } if ((numberValue << 28) == 0) { numberValue >>= 4; i += 4; } if ((numberValue << 30) == 0) { numberValue >>= 2; i += 2; } if ((numberValue << 31) == 0) { ++i; } } return i; } }