```
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0) return false;
if (x < 10) return true;
int high = 0, low = 0, weight = 1;
while (x / weight > 9)
weight *= 10;
while (x > 0)
{
high = x / weight;
low = x % 10;
if (low != high)
return false;
//x -= (high * weight);
x %= weight;
x /= 10;
weight /= 100;
}
return true;
}
};
```