public static boolean isValidSubnet(int hash){
  int bits=0;
  while ((hash & 0b1) == 0 && bits < 31) {
    hash>>=1;
    bits++;
  }
  while ((hash & 0b1) == 1 && bits < 32) {
    hash>>=1;
    bits++;
  }
  return bits == 32;
}

public static boolean isValidSubnet ( int hash ) { int bits = 0 ; while ( ( hash & 0b1 ) == 0 && bits < 31 ) { hash >>= 1 ; bits ++ ; } while ( ( hash & 0b1 ) == 1 && bits < 32 ) { hash >>= 1 ; bits ++ ; } return bits == 32 ; }
makes sure there are no high bits less significant than low bits .
