public boolean isPalindrome(int x) {

    if (x < 0) {
      return false;
    }

    int div = 1;
    while (x / div >= 10) { // this equal is important
      div *= 10;
    }

System.out.println(div);
    while (x != 0) {
    	
    	System.out.println(x);
      int lastBit = x % 10;
      int firstBit = x / div;
System.out.println(lastBit + " " + firstBit);
      if (lastBit != firstBit) {
        return false;
      }
      x = (x % div) / 10;
      
      div /= 100;
    }

    return true;
  }