I treat the number as a string and compare the number's digits.

```
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0) return false;
long long int i, j = 10;
for (i = 10; x / i; i *= 10); // get the digits of x
if (x == 0) i *= 10;
for (; j < i; i /= 10, j *= 10) { // the expression (x % i) / (i / 10) can get a number's specific digital, for example, (123 % 1000) / (1000 / 10) is 1
if ((x % i) / (i / 10) != (x % j) / (j / 10)) return false;
}
return true;
}
};
```