```
int piece(int x,int index){
return int(x/pow(10,index-1))%10;
}
bool isPalindrome(int x) {
if(x<0)return false;
int len = log(x)/log(10)+1;
for(int i=1;i<=len/2;i++){
if(piece(x,i)!=piece(x,len+1-i))return false;
}
return true;
}
```