```
public class Solution {
public boolean isPalindrome(int x) {
if (x < 0)
return false;
int bits = 1;
while (x / bits >= 10) {
bits *= 10;// Determine the highest position
}
while (x > 0) {
int high = x / bits;
int low = x % 10;
if (high != low)
return false;
x -= high * bits;
x /= 10;
bits /= 100;// Because compare once,remove the first and last digits.
}
return true;
}
}
```